Validators
Validators or solvers solve tasks and vote on validity of solved tasks.
The Validator model
The Validator model contains all information about Validator
Properties
- Name
staked
- Type
- uint256
- required
- Defaults to
- Description
How much the validator has staked
- Name
addr
- Type
- address
- required
- Defaults to
- Description
Address of the validator
Retrieve validator
Look up a validator by their address.
Request
import { ethers } from 'ethers'
import Config from './config.json'
import EngineArtifact from './artifacts/EngineV1.sol/EngineV1.json';
const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const engine = new ethers.Contract(
Config.engineAddress,
EngineArtifact.abi,
provider,
)
// validator address here
const address = '0x...'
const validator = await engine.validators(address);
const { staked, addr } = validator;
Become validator
Users who want to be validators must deposit validatorDeposit
Arbius to become a validator. At the beginning, this is 0 for bootstrapping of network. To continue being a validator, you must keep a staked balance of at least validatorMinimum
which is some number less than validatorDeposit
. The only thing that reduces your staked balance is being slashed on a task or vote, which reduces your staked balance by slashAmount
.
Request
import { ethers } from 'ethers'
import Config from './config.json'
import EngineArtifact from './artifacts/EngineV1.sol/EngineV1.json';
const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const wallet = new ethers.Wallet(
process.env.PRIVATE_KEY,
provider,
);
const engine = new ethers.Contract(
Config.engineAddress,
EngineArtifact.abi,
wallet,
)
// ensure you have granted BaseToken allowance of getValidatorMinimum()
const tx = await engine.becomeValidator()
const receipt = await tx.wait();
Exit Validation
Validators who wish to withdraw their staked balance and cease being validators must first perform a call to initiateExitValidator
, and after a period of time (exitValidatorMinUnlockTime
) may call exitValidator
to withdraw staked funds.
Request
import { ethers } from 'ethers'
import Config from './config.json'
import EngineArtifact from './artifacts/EngineV1.sol/EngineV1.json';
const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const wallet = new ethers.Wallet(
process.env.PRIVATE_KEY,
provider,
);
const engine = new ethers.Contract(
Config.engineAddress,
EngineArtifact.abi,
wallet,
)
const tx = await engine.initiateExitValidator()
const receipt = await tx.wait();
// after waiting 1 day
const tx = await engine.exitValidator()
const receipt = await tx.wait();