-
Notifications
You must be signed in to change notification settings - Fork 0
/
getPagedForgersStakesByUser.js
31 lines (26 loc) · 1.32 KB
/
getPagedForgersStakesByUser.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
// Right-click on the script name and hit "Run" to execute
(async () => {
try {
console.log('Running forging stake script - getPagedForgersStakesByUser...');
// ##### ONLY SET THE FOLLOWING VALUES #####
const OWNER_ADDRESS = ""; // If owner is different from caller, specify it here.
const START_INDEX = 0; // Initial stake index to be returned. Update this value to get the next page.
const PAGE_SIZE = 10; // Number of stakes to be returned. Update this value to get more or less stakes.
// ##### DO NOT MAKE ANY MORE CHANGES TO THE SCRIPT #####
const accounts = await web3.eth.getAccounts();
const callerAddress = accounts[0];
const ownerAddress = !OWNER_ADDRESS ? callerAddress : OWNER_ADDRESS;
// This is the contract address for the Forger Stake Delegation contract. DO NOT CHANGE THIS VALUE.
const contractAddress = "0x0000000000000000000022222222222222222222";
const abi = require("./abi/forger_stake_delegation.json");
const contract = new web3.eth.Contract(abi, contractAddress);
await contract.methods.getPagedForgersStakesByUser(ownerAddress, START_INDEX, PAGE_SIZE).call().then(response => {
console.log({
nextStake: response["0"],
stakes: response["1"]
})
});
} catch (e) {
console.log("Error:" + e.message);
}
})()