-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinteract-transfer.js
29 lines (24 loc) · 1.09 KB
/
interact-transfer.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
const { loadWallet } = require('./utils/load-wallet');
const { connectArweave } = require('./utils/connect-arweave');
const { connectPstContract } = require('./utils/connect-pst-contract');
const { contractTxId } = require('./utils/contract-tx-id');
const { mineBlock } = require('./utils/mine-block');
module.exports.interactTransfer = async function (host, port, protocol, target, walletJwk) {
const arweave = connectArweave(host, port, protocol);
const wallet = await loadWallet(arweave, walletJwk, target, true);
const txId = contractTxId(target);
const pst = await connectPstContract(arweave, wallet, txId, target);
const transferId = await pst.transfer({
target: 'uhE-QeYS8i4pmUtnxQyHD7dzXFNaJ9oMK-IM-QPNY6M',
qty: 555,
});
await mineBlock(arweave);
const state = await pst.currentState();
console.log('Updated state:', state);
console.log('Contract tx id', txId);
if (target == 'testnet') {
console.log(`Check transfer interaction at https://sonar.warp.cc/#/app/interaction/${transferId}?network=testnet`);
} else {
console.log('Transfer tx id', transferId);
}
};