Skip to content

Commit

Permalink
Creating Asset and submitting to testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
praszad committed May 11, 2023
1 parent 835aa04 commit c40258d
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
package-lock.json
.env
3 changes: 3 additions & 0 deletions README.md
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
42 changes: 42 additions & 0 deletions index.js
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();
24 changes: 24 additions & 0 deletions package.json
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"
}
}

0 comments on commit c40258d

Please sign in to comment.