Voting for a Validator
UI
Ethers

Step2: Click on
Voting to Validator
, enter validator address
and submit the amount
you want to stake/vote
import { getDefaultProvider, Wallet } from "ethers";
import { StakeManager__factory } from "@rei-network/contracts";
const provider = getDefaultProvider("https://rpc-mainnet.rei.network");
const wallet = new Wallet("yourPrivateKey", provider);
const stakeManager = StakeManager__factory.connect(
"0x0000000000000000000000000000000000001001",
wallet
);
stakeManager
.stake("validatorAddress", "receiveAddress", {
value: "stakeAmount",
})
.then(() => {
// ...
})
.catch(() => {
// ...
});
Why am I not able to Stake?Check if you haveREI
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
UI
Ethers
Once you log in 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.
import { getDefaultProvider, Wallet, BigNumber } from "ethers";
import {
CommissionShare__factory,
StakeManager__factory,
CommissionShare,
} from "@rei-network/contracts";
const provider = getDefaultProvider("https://rpc-mainnet.rei.network");
const wallet = new Wallet("yourPrivateKey", provider);
const stakeManager = StakeManager__factory.connect(
"0x0000000000000000000000000000000000001001",
wallet
);
(async () => {
try {
let cs: CommissionShare;
// get commission share contract address from validators
{
const result = await stakeManager.validators("validatorAddress");
cs = CommissionShare__factory.connect(result.commissionShare, wallet);
}
// approve for stake manager
{
const tx = await cs.approve(
"0x0000000000000000000000000000000000001001",
"approveAmount"
);
await tx.wait();
}
// start unstake
{
const tx = await stakeManager.startUnstake(
"validatorAddress",
"receiveAddress",
"numberOfShares"
);
await tx.wait();
const receipt = await provider.getTransactionReceipt(tx.hash);
for (const log of receipt.logs) {
if (
log.address === "0x0000000000000000000000000000000000001001" &&
log.topics[0] ===
"0x020b3ba91672f551cfd1f7abf4794b3fb292f61fd70ffd5a34a60cdd04078e50" // StartUnstake event topic
) {
const bn = BigNumber.from(log.topics[1]);
console.log("your unstakeId is:", bn.toNumber());
break;
}
}
}
} catch (err) {
// ...
}
})();
Note: There will be a vesting period after unvote/unstake, find the pending unstake record in `Pending Unstake` Dashboard
UI
Ethers
You can find unstake list in
Pending Unstaked
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.
import { getDefaultProvider, Wallet } from "ethers";
import { StakeManager__factory } from "@gxchain2/contracts";
const wallet = new Wallet(
"yourPrivKey",
getDefaultProvider("https://rpc-mainnet.rei.network")
);
const stakeManager = StakeManager__factory.connect(
"0x0000000000000000000000000000000000001001",
wallet
);
stakeManager
.unstake("unstakeId")
.then(() => {
// ...
})
.catch((err) => {
// ...
});
Last modified 10mo ago