mirror of
https://github.com/bigchaindb/site.git
synced 2024-11-22 09:46:57 +01:00
Merge pull request #266 from bigchaindb/tutorial-token
Fix transfer transaction
This commit is contained in:
commit
19ac5b1200
@ -37,7 +37,7 @@ const nTokens = 10000
|
|||||||
let tokensLeft
|
let tokensLeft
|
||||||
const tokenCreator = new BigchainDB
|
const tokenCreator = new BigchainDB
|
||||||
.Ed25519Keypair(bip39.mnemonicToSeed('seedPhrase').slice(0,32))
|
.Ed25519Keypair(bip39.mnemonicToSeed('seedPhrase').slice(0,32))
|
||||||
|
let createTxId
|
||||||
function tokenLaunch() {
|
function tokenLaunch() {
|
||||||
// Construct a transaction payload
|
// Construct a transaction payload
|
||||||
const tx = BigchainDB.Transaction.makeCreateTransaction({
|
const tx = BigchainDB.Transaction.makeCreateTransaction({
|
||||||
@ -62,6 +62,7 @@ function tokenLaunch() {
|
|||||||
// Send the transaction off to BigchainDB
|
// Send the transaction off to BigchainDB
|
||||||
conn.postTransactionCommit(txSigned)
|
conn.postTransactionCommit(txSigned)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
createTxId = res.id
|
||||||
tokensLeft = nTokens
|
tokensLeft = nTokens
|
||||||
document.body.innerHTML ='<h3>Transaction created</h3>';
|
document.body.innerHTML ='<h3>Transaction created</h3>';
|
||||||
// txSigned.id corresponds to the asset id of the tokens
|
// txSigned.id corresponds to the asset id of the tokens
|
||||||
@ -91,12 +92,7 @@ function transferTokens() {
|
|||||||
|
|
||||||
// Search outputs of the transactions belonging the token creator
|
// Search outputs of the transactions belonging the token creator
|
||||||
// False argument to retrieve unspent outputs
|
// False argument to retrieve unspent outputs
|
||||||
conn.listOutputs(tokenCreator.publicKey, 'false')
|
conn.getTransaction(createTxId)
|
||||||
.then((txs) => {
|
|
||||||
// Just one transaction available with outputs not being spent by
|
|
||||||
// tokenCreator. Therefore, txs[0]
|
|
||||||
return conn.getTransaction(txs[0].transaction_id)
|
|
||||||
})
|
|
||||||
.then((txOutputs) => {
|
.then((txOutputs) => {
|
||||||
// Create transfer transaction
|
// Create transfer transaction
|
||||||
const createTranfer = BigchainDB.Transaction
|
const createTranfer = BigchainDB.Transaction
|
||||||
|
Loading…
Reference in New Issue
Block a user