-
Notifications
You must be signed in to change notification settings - Fork 1
/
end.js
58 lines (49 loc) · 1.86 KB
/
end.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const {BN, Long, bytes, units} = require('@zilliqa-js/util');
const {Zilliqa} = require('@zilliqa-js/zilliqa');
const {
toBech32Address,
getAddressFromPrivateKey,
} = require('@zilliqa-js/crypto');
async function main() {
const zilliqa = new Zilliqa('https://dev-api.zilliqa.com');
const CHAIN_ID = 333;
const MSG_VERSION = 1;
const VERSION = bytes.pack(CHAIN_ID, MSG_VERSION);
privkey = '07e0b1d1870a0ba1b60311323cb9c198d6f6193b2219381c189afab3f5ac41a9';
zilliqa.wallet.addByPrivateKey(
privkey
);
const address = getAddressFromPrivateKey(privkey);
console.log("Your account address is:");
console.log(`${address}`);
const myGasPrice = units.toQa('2000', units.Units.Li); // Gas Price that will be used by all transactions
const nftAddr = toBech32Address("79d662e621c08521a20f80e953417d981ddef0a6");
try {
const contract = zilliqa.contracts.at(nftAddr);
const callTx = await contract.callWithoutConfirm(
'AuctionEnd',
[
],
{
// amount, gasPrice and gasLimit must be explicitly provided
version: VERSION,
amount: new BN(0),
gasPrice: myGasPrice,
gasLimit: Long.fromNumber(10000),
}
);
// check the pending status
const pendingStatus = await zilliqa.blockchain.getPendingTxn(callTx.id);
console.log(`Pending status is: `);
console.log(pendingStatus.result);
// process confirm
console.log(`The transaction id is:`, callTx.id);
console.log(`Waiting transaction be confirmed`);
const confirmedTxn = await callTx.confirm(callTx.id);
console.log(`The transaction status is:`);
console.log(JSON.stringify(confirmedTxn.receipt));
} catch (err) {
console.log(err);
}
}
main();