Created
December 18, 2020 05:41
-
-
Save kctam/c8ea7b907108c69023b05e99e3535ca9 to your computer and use it in GitHub Desktop.
Algorand ASA demo in JavaScript SDK
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 algosdk = require('algosdk'); | |
const server="https://testnet-algorand.api.purestake.io/ps2"; | |
const port=""; | |
const token={ | |
"x-api-key": "mV *** BY" // fill in yours | |
}; | |
var bob_mnemonic = "truth erase *** above magic"; // fill in yours | |
var bobAccount = algosdk.mnemonicToSecretKey(bob_mnemonic); | |
let client = new algosdk.Algodv2(token, server, port); | |
(async () => { | |
let assetID = 13300122; // change to your own assetID | |
let params = await client.getTransactionParams().do(); | |
let sender = bobAccount.addr; | |
let recipient = sender; | |
let revocationTarget = undefined; | |
let closeRemainderTo = undefined; | |
let note = undefined; | |
let amount = 0; | |
let txn = algosdk.makeAssetTransferTxnWithSuggestedParams(sender, recipient, closeRemainderTo, revocationTarget, | |
amount, note, assetID, params); | |
let rawSignedTxn = txn.signTxn(bobAccount.sk) | |
let tx = (await client.sendRawTransaction(rawSignedTxn).do()); | |
console.log("Transaction : " + tx.txId); | |
})().catch(e => { | |
console.log(e); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment