Created
December 18, 2020 05:37
-
-
Save kctam/123366ee3fe8cc29818b1f4e9450f440 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 alice_mnemonic = "cash riot *** able can"; // fill in yours | |
var aliceAccount = algosdk.mnemonicToSecretKey(alice_mnemonic); | |
let client = new algosdk.Algodv2(token, server, port); | |
(async () => { | |
let params = await client.getTransactionParams().do(); | |
let note = undefined; | |
let addr = aliceAccount.addr; | |
let defaultFrozen = false; | |
let decimals = 0; | |
let totalIssuance = 1000000; | |
let unitName = "KCCOIN"; | |
let assetName = "KC Coin"; | |
let assetURL = "http://someurl"; | |
let assetMetadataHash = "01234567890123456789012345678901"; | |
let manager = aliceAccount.addr; | |
let reserve = aliceAccount.addr; | |
let freeze = aliceAccount.addr; | |
let clawback = aliceAccount.addr; | |
let txn = algosdk.makeAssetCreateTxnWithSuggestedParams(addr, note, | |
totalIssuance, decimals, defaultFrozen, manager, reserve, freeze, | |
clawback, unitName, assetName, assetURL, assetMetadataHash, params); | |
let rawSignedTxn = txn.signTxn(aliceAccount.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