Skip to content

Instantly share code, notes, and snippets.

@kctam
Created December 18, 2020 05:47
Show Gist options
  • Save kctam/4934b68bd0abbde6d899ca98c574b03c to your computer and use it in GitHub Desktop.
Save kctam/4934b68bd0abbde6d899ca98c574b03c to your computer and use it in GitHub Desktop.
Algorand ASA demo in JavaScript SDK
const algosdk = require('algosdk');
const server="https://testnet-algorand.api.purestake.io/ps2";
const port="";
const token={
"x-api-key": "mV *** BY"
};
var bob_mnemonic = "truth erase *** above magic"; // fill in yours
var bobAccount = algosdk.mnemonicToSecretKey(bob_mnemonic);
var aliceAddress = '5SL7MUMPYFNDBHUD4L7J4LJRQCQWXQUD3RDK7SBGIDWPH3ZFK47BTH43HE'; // change to yours
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 = aliceAddress;
let revocationTarget = undefined;
let closeRemainderTo = aliceAddress;
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