Voting for a Validator

Vote/Stake to a Validator

UI
Ethers
Step2: Click on Voting to Validator, enter validator address and submit the amount you want to stake/vote
1
import { getDefaultProvider, Wallet } from "ethers";
2
import { StakeManager__factory } from "@rei-network/contracts";
3
4
const provider = getDefaultProvider("https://rpc-mainnet.rei.network");
5
6
const wallet = new Wallet("yourPrivateKey", provider);
7
8
const stakeManager = StakeManager__factory.connect(
9
"0x0000000000000000000000000000000000001001",
10
wallet
11
);
12
13
stakeManager
14
.stake("validatorAddress", "receiveAddress", {
15
value: "stakeAmount",
16
})
17
.then(() => {
18
// ...
19
})
20
.catch(() => {
21
// ...
22
});
Copied!

Why am I not able to Stake?

Check if you have REI in your wallet on REI Network

I've staked to 0x...abcd, but not record find in ACTIVE VALIDATOR?

Because only the 21 nodes with the most votes are currently displayed in the list of activated nodes

UnVote/UnStake

UI
Ethers
Once you login you will find this on the Validator of the Staking Dashboard. Here you will see an Unstake button for each of the validators. Click on the Unstake button for whichever validator that you had staked to.
1
import { getDefaultProvider, Wallet, BigNumber } from "ethers";
2
import {
3
CommissionShare__factory,
4
StakeManager__factory,
5
CommissionShare,
6
} from "@rei-network/contracts";
7
8
const provider = getDefaultProvider("https://rpc-mainnet.rei.network");
9
10
const wallet = new Wallet("yourPrivateKey", provider);
11
12
const stakeManager = StakeManager__factory.connect(
13
"0x0000000000000000000000000000000000001001",
14
wallet
15
);
16
17
(async () => {
18
try {
19
let cs: CommissionShare;
20
// get commission share contract address from validators
21
{
22
const result = await stakeManager.validators("validatorAddress");
23
cs = CommissionShare__factory.connect(result.commissionShare, wallet);
24
}
25
26
// approve for stake manager
27
{
28
const tx = await cs.approve(
29
"0x0000000000000000000000000000000000001001",
30
"approveAmount"
31
);
32
await tx.wait();
33
}
34
35
// start unstake
36
{
37
const tx = await stakeManager.startUnstake(
38
"validatorAddress",
39
"receiveAddress",
40
"numberOfShares"
41
);
42
await tx.wait();
43
const receipt = await provider.getTransactionReceipt(tx.hash);
44
for (const log of receipt.logs) {
45
if (
46
log.address === "0x0000000000000000000000000000000000001001" &&
47
log.topics[0] ===
48
"0x020b3ba91672f551cfd1f7abf4794b3fb292f61fd70ffd5a34a60cdd04078e50" // StartUnstake event topic
49
) {
50
const bn = BigNumber.from(log.topics[1]);
51
console.log("your unstakeId is:", bn.toNumber());
52
break;
53
}
54
}
55
}
56
} catch (err) {
57
// ...
58
}
59
})();
Copied!
Note: There will be a vesting period after unvote/unstake, find the pending unstake record in `Pending Unstake` Dashboard

Claim Vested Stake

UI
Ethers
You can find unstake list in PENDING UNSTAKE Dashboard.
Once the vesting period is completed, the UNSTAKE button will be enabled and you can then claim your staked tokens to your wallet now.
1
import { getDefaultProvider, Wallet } from "ethers";
2
import { StakeManager__factory } from "@gxchain2/contracts";
3
4
const wallet = new Wallet(
5
"yourPrivKey",
6
getDefaultProvider("https://rpc-mainnet.rei.network")
7
);
8
9
const stakeManager = StakeManager__factory.connect(
10
"0x0000000000000000000000000000000000001001",
11
wallet
12
);
13
14
stakeManager
15
.unstake("unstakeId")
16
.then(() => {
17
// ...
18
})
19
.catch((err) => {
20
// ...
21
});
Copied!