added demo

This commit is contained in:
Gregory Coppola
2021-07-15 11:41:23 -05:00
parent 4942504417
commit c9f5689e8b
4 changed files with 551 additions and 24411 deletions

9
demo/key.js Normal file
View File

@@ -0,0 +1,9 @@
import { createStacksPrivateKey, makeRandomPrivKey, getPublicKey } from '@blockstack/stacks-transactions';
// Random key
const privateKey = makeRandomPrivKey();
// Get public key from private
const publicKey = getPublicKey(privateKey);
console.log({privateKey, publicKey})

30
demo/transaction1.js Normal file
View File

@@ -0,0 +1,30 @@
import {
makeSTXTokenTransfer,
makeStandardSTXPostCondition,
broadcastTransaction,
} from '@stacks/transactions';
import { StacksTestnet, StacksMainnet } from '@stacks/network';
const BigNum = require('bn.js');
// for mainnet, use `StacksMainnet()`
const network = new StacksTestnet();
const txOptions = {
recipient: 'SP3FGQ8Z7JY9BWYZ5WM53E0M9NK7WHJF0691NZ159',
amount: new BigNum(12345),
senderKey: 'b244296d5907de9864c0b0d51f98a13c52890be0404e83f273144cd5b9960eed01',
network,
memo: 'test memo',
nonce: new BigNum(0), // set a nonce manually if you don't want builder to fetch from a Stacks node
fee: new BigNum(200), // set a tx fee if you don't want the builder to estimate
anchorMode: AnchorMode.Any
};
const transaction = await makeSTXTokenTransfer(txOptions);
// to see the raw serialized tx
const serializedTx = transaction.serialize().toString('hex');
// broadcasting transaction to the specified network
broadcastTransaction(transaction, network);

24917
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
{
"type": "module",
"name": "stacks.js",
"version": "1.4.1",
"private": true,
@@ -26,7 +27,10 @@
"typedoc": "^0.20.35",
"typescript": "^4.2.4"
},
"dependencies": {},
"dependencies": {
"@blockstack/stacks-transactions": "^0.7.0",
"@stacks/transactions": "^2.0.0-beta.1"
},
"scripts": {
"bootstrap": "lerna bootstrap",
"build": "lerna run build",