-
-
Save apopiak/d9fa3952b5cd520943e12d689824391c to your computer and use it in GitHub Desktop.
Asset Tx Payment Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty'; | |
const CHARLIE = '5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y'; | |
// assumes minimum balance of 10000 | |
// CHARLIE needs to have at least 50000 in his account | |
const randomAmount = 40000; | |
// Create a extrinsic, transferring randomAmount units to Bob. | |
const transfer = api.tx.assets.transfer(0, BOB, randomAmount); | |
// Sign and Send the transaction | |
await transfer.signAndSend(CHARLIE, {assetId: 0}, ({ events = [], status }) => { | |
if (status.isInBlock) { | |
console.log('Successful transfer of ' + randomAmount + ' with hash ' + status.asInBlock.toHex()); | |
} else { | |
console.log('Status of transfer: ' + status.type); | |
} | |
events.forEach(({ phase, event: { data, method, section } }) => { | |
console.log(phase.toString() + ' : ' + section + '.' + method + ' ' + data.toString()); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment