-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathasa_deposit.js
30 lines (24 loc) · 940 Bytes
/
asa_deposit.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
import { encodeUint64, getApplicationAddress, makeApplicationNoOpTxn, } from "algosdk";
import { algodClient, submitTransaction } from "./utils.js";
import { user } from "./config.js";
export const asa_deposit = async (appId, asset_id) => {
// get transaction params
const params = await algodClient.getTransactionParams().do();
// deposit
const enc = new TextEncoder();
const depositAmount = 1000;
let txn = makeApplicationNoOpTxn(
user.addr,
{ ...params, flatFee: true, fee: 3000 }, // must pay for inner transaction
appId,
[enc.encode("asa_deposit"), encodeUint64(depositAmount)],
undefined,
undefined,
[asset_id],//asset that we transfer
undefined,
undefined,
getApplicationAddress(appId), // rekey to application address
);
let txId = await submitTransaction(txn, user.sk);
console.log("Deposit transaction id: " + txId);
}