-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating Asset and submitting to testnet
- Loading branch information
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
package-lock.json | ||
.env |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# algo_learn | ||
|
||
Learning algorand using algo docs | ||
Asset creation | ||
Submitting it to the Testnet |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const algosdk = require('algosdk'); | ||
const ak = algosdk; | ||
const MNEMONICS = | ||
'patrol force swarm purse razor clock next issue erode install wear rack case coast differ silver unknown order film vintage giraffe unhappy top about ahead'; | ||
|
||
async function main() { | ||
// const account = algosdk.generateAccount(); | ||
// console.log(account); | ||
// const mnemonics = algosdk.secretKeyToMnemonic(account.sk); | ||
// console.log({ mnemonics }); | ||
const account = ak.mnemonicToSecretKey(MNEMONICS); | ||
// console.log({ account }); | ||
const algodToken = ''; | ||
const algodServer = 'https://testnet-api.algonode.cloud'; | ||
const algodPort = undefined; | ||
const algoClient = new ak.Algodv2(algodToken, algodServer, algodPort); | ||
// console.log(algoClient); | ||
const suggestedParams = await algoClient.getTransactionParams().do(); | ||
// console.log({ suggestedParams }); | ||
const myNewTestAsset = ak.makeAssetCreateTxnWithSuggestedParamsFromObject({ | ||
from: account.addr, | ||
decimals: 1, | ||
suggestedParams, | ||
defaultFrozen: false, | ||
total: 1000000, | ||
assetName: 'prz-test-01', | ||
assetURL: 'https://testnet-api.algonode.cloud', | ||
clawback: account.addr, | ||
freeze: account.addr, | ||
manager: account.addr, | ||
reserve: account.addr, | ||
unitName: 'prz01', | ||
assetURL: 'https://testnet-api.algonode.cloud' | ||
}); | ||
let sign = myNewTestAsset.signTxn(account.sk); | ||
let { txId } = await algoClient.sendRawTransaction(sign).do(); | ||
console.log({ txId }); | ||
let results = await algosdk.waitForConfirmation(algoClient, txId, 4); | ||
console.log(results); | ||
} | ||
|
||
main(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "algo_learn", | ||
"version": "1.0.0", | ||
"description": "Learning algorand using algo docs", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/praszad/algo_learn.git" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/praszad/algo_learn/issues" | ||
}, | ||
"homepage": "https://github.com/praszad/algo_learn#readme", | ||
"dependencies": { | ||
"algosdk": "^2.3.0", | ||
"dotenv": "^16.0.3" | ||
} | ||
} |