-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_asset_pstake_temp.js
42 lines (32 loc) · 1.31 KB
/
generate_asset_pstake_temp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Algorand Algod (v2) example
// Send transaction on TestNet
require('dotenv').config();
const algosdk = require('algosdk');
const baseServer = "https://testnet-algorand.api.purestake.io/ps2";
const port = "";
const token = {
'X-API-key': process.env.APIKEY
}
let algodClient = new algosdk.Algodv2(token, baseServer, port);
(async () => {
let params = await algodClient.getTransactionParams().do();
let amount = Math.floor(Math.random() * 1000);
var mnemonic = "code thrive mouse code badge example pride stereo sell viable adjust planet text close erupt embrace nature upon february weekend humble surprise shrug absorb faint";
var recoveredAccount = algosdk.mnemonicToSecretKey(mnemonic);
let txn = {
"from": recoveredAccount.addr,
"to": "UUOB7ZC2IEE4A7JO4WY4TXKXWDFNATM43TL73IZRAFIFFOE6ORPKC7Q62E",
"fee": 1,
"amount": amount,
"firstRound": params.firstRound,
"lastRound": params.lastRound,
"genesisID": params.genesisID,
"genesisHash": params.genesisHash,
"note": new Uint8Array(0),
};
let signedTxn = algosdk.signTransaction(txn, recoveredAccount.sk);
let sendTx = await algodClient.sendRawTransaction(signedTxn.blob).do();
console.log("Transaction : " + sendTx.txId);
})().catch(e => {
console.log(e);
});