-
Notifications
You must be signed in to change notification settings - Fork 0
/
delegate.js
36 lines (29 loc) · 1.8 KB
/
delegate.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
// Right-click on the script name and hit "Run" to execute
(async () => {
try {
console.log('Running forging stake script - delegate...');
// Select one existing forger, or create your own and set the following values:
// ##### ONLY SET THE FOLLOWING VALUES #####
const AMOUNT = "0.00"; // Amount of ZEN of the new stake
const YOUR_BLOCK_SIGN_PUBKEY = ""; // The public key that will sign the block when forged; populate this with the value of "Block Sign Public Key" from the forger you will delegate to.
const YOUR_VRF_PUBKEY = ""; // The "VRF Public Key" of the forger you will delegate to.
// ##### DO NOT MAKE ANY MORE CHANGES TO THE SCRIPT #####
// This is the contract address for the Forger Stake Delegation contract. DO NOT CHANGE THIS VALUE.
const contractAddress = "0x0000000000000000000022222222222222222222";
const accounts = await web3.eth.getAccounts();
const ownerAddress = accounts[0];
const abi = require("./abi/forger_stake_delegation.json");
const contract = new web3.eth.Contract(abi, contractAddress, {from: ownerAddress});
console.log('Account ' + ownerAddress);
const value = web3.utils.toWei(AMOUNT.toString(), "ether");
const blockSignPublicKey = "0x" + YOUR_BLOCK_SIGN_PUBKEY;
const forgerVrfPublicKey = "0x" + YOUR_VRF_PUBKEY;
const first32BytesForgerVrfPublicKey = forgerVrfPublicKey.substring(0, 66);
const lastByteForgerVrfPublicKey = "0x" + forgerVrfPublicKey.substring(66, 68);
console.log("Sending delegate transaction...");
await contract.methods.delegate(blockSignPublicKey,first32BytesForgerVrfPublicKey,lastByteForgerVrfPublicKey,ownerAddress).send({value: value}).then(console.log);
console.log("Transaction completed.");
} catch (e) {
console.log("Error:" + e.message);
}
})()