SignerChange Event
This JavaScript script utilizes the Web3.js library to interact with a smart contract. It searches for events called 'SignerChange' within a range of specific validator identifiers. The script retrieves and displays information about changes in signatories ('SignerChange') for each validator in the specified range, providing the addresses of the old and new signatories for each event. This type of analysis is useful for tracking and auditing changes in signatories in a smart contract.
const { Web3 } = require('web3');
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
const readline = require('readline');
const { promisify } = require('util');
const web3 = new Web3('https://your-rpc-ethereum');
const contractAddress = '0xa59c847bd5ac0172ff4fe912c5d29e5a71a7512b'
const contractABI = [
{
"inputs": [
{
"internalType": "address",
"name": "_registry",
"type": "address"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "fee",
"type": "uint256"
}
],
"name": "ClaimFee",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "totalAmount",
"type": "uint256"
}
],
"name": "ClaimRewards",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "newValidatorId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "oldValidatorId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "ConfirmAuction",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "rewards",
"type": "uint256"
}
],
"name": "DelegatorClaimedRewards",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "totalStaked",
"type": "uint256"
}
],
"name": "DelegatorRestaked",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "DelegatorUnstaked",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "newDynasty",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "oldDynasty",
"type": "uint256"
}
],
"name": "DynastyValueChange",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "exitEpoch",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "signer",
"type": "address"
}
],
"name": "Jailed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "newProposerBonus",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "oldProposerBonus",
"type": "uint256"
}
],
"name": "ProposerBonusChange",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "total",
"type": "uint256"
}
],
"name": "Restaked",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "newReward",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "oldReward",
"type": "uint256"
}
],
"name": "RewardUpdate",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "tokens",
"type": "uint256"
}
],
"name": "ShareBurned",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "tokens",
"type": "uint256"
}
],
"name": "ShareMinted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "nonce",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "oldSigner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newSigner",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes",
"name": "signerPubkey",
"type": "bytes"
}
],
"name": "SignerChange",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "nonce",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "Slashed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "nonce",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "newAmount",
"type": "uint256"
}
],
"name": "StakeUpdate",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "nonce",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "activationEpoch",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "total",
"type": "uint256"
},
{
"indexed": false,
"internalType": "bytes",
"name": "signerPubkey",
"type": "bytes"
}
],
"name": "Staked",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "auctionAmount",
"type": "uint256"
}
],
"name": "StartAuction",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "newThreshold",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "oldThreshold",
"type": "uint256"
}
],
"name": "ThresholdChange",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "fee",
"type": "uint256"
}
],
"name": "TopUpFee",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "signer",
"type": "address"
}
],
"name": "UnJailed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "nonce",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "deactivationEpoch",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "UnstakeInit",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "total",
"type": "uint256"
}
],
"name": "Unstaked",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "newCommissionRate",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "oldCommissionRate",
"type": "uint256"
}
],
"name": "UpdateCommissionRate",
"type": "event"
},
{
"constant": true,
"inputs": [],
"name": "getAccountStateRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "accountStateRoot",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
}
],
"name": "getStakerDetails",
"outputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "reward",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "activationEpoch",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "deactivationEpoch",
"type": "uint256"
},
{
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"internalType": "uint256",
"name": "_status",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
}
],
"name": "getValidatorContractAddress",
"outputs": [
{
"internalType": "address",
"name": "ValidatorContract",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "isOwner",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "fee",
"type": "uint256"
}
],
"name": "logClaimFee",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "totalAmount",
"type": "uint256"
}
],
"name": "logClaimRewards",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "newValidatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "oldValidatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "logConfirmAuction",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "rewards",
"type": "uint256"
}
],
"name": "logDelegatorClaimedRewards",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "totalStaked",
"type": "uint256"
}
],
"name": "logDelegatorRestaked",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "logDelegatorUnstaked",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "newDynasty",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "oldDynasty",
"type": "uint256"
}
],
"name": "logDynastyValueChange",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "exitEpoch",
"type": "uint256"
},
{
"internalType": "address",
"name": "signer",
"type": "address"
}
],
"name": "logJailed",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getAccountStateRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "accountStateRoot",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
}
],
"name": "getStakerDetails",
"outputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "reward",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "activationEpoch",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "deactivationEpoch",
"type": "uint256"
},
{
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"internalType": "uint256",
"name": "_status",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
}
],
"name": "getValidatorContractAddress",
"outputs": [
{
"internalType": "address",
"name": "ValidatorContract",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "isOwner",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "fee",
"type": "uint256"
}
],
"name": "logClaimFee",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "totalAmount",
"type": "uint256"
}
],
"name": "logClaimRewards",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "newValidatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "oldValidatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "logConfirmAuction",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "rewards",
"type": "uint256"
}
],
"name": "logDelegatorClaimedRewards",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "totalStaked",
"type": "uint256"
}
],
"name": "logDelegatorRestaked",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "logDelegatorUnstaked",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "newDynasty",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "oldDynasty",
"type": "uint256"
}
],
"name": "logDynastyValueChange",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "exitEpoch",
"type": "uint256"
},
{
"internalType": "address",
"name": "signer",
"type": "address"
}
],
"name": "logJailed",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getAccountStateRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "accountStateRoot",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
}
],
"name": "getStakerDetails",
"outputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "reward",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "activationEpoch",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "deactivationEpoch",
"type": "uint256"
},
{
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"internalType": "uint256",
"name": "_status",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
}
],
"name": "getValidatorContractAddress",
"outputs": [
{
"internalType": "address",
"name": "ValidatorContract",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "isOwner",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "fee",
"type": "uint256"
}
],
"name": "logClaimFee",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "totalAmount",
"type": "uint256"
}
],
"name": "logClaimRewards",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "newValidatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "oldValidatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "logConfirmAuction",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "rewards",
"type": "uint256"
}
],
"name": "logDelegatorClaimedRewards",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "totalStaked",
"type": "uint256"
}
],
"name": "logDelegatorRestaked",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "logDelegatorUnstaked",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "newDynasty",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "oldDynasty",
"type": "uint256"
}
],
"name": "logDynastyValueChange",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "exitEpoch",
"type": "uint256"
},
{
"internalType": "address",
"name": "signer",
"type": "address"
}
],
"name": "logJailed",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getAccountStateRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "accountStateRoot",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
}
],
"name": "getStakerDetails",
"outputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "reward",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "activationEpoch",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "deactivationEpoch",
"type": "uint256"
},
{
"internalType": "address",
"name": "signer",
"type": "address"
},
{
"internalType": "uint256",
"name": "_status",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
}
],
"name": "getValidatorContractAddress",
"outputs": [
{
"internalType": "address",
"name": "ValidatorContract",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "isOwner",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "fee",
"type": "uint256"
}
],
"name": "logClaimFee",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "totalAmount",
"type": "uint256"
}
],
"name": "logClaimRewards",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "newValidatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "oldValidatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "logConfirmAuction",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "rewards",
"type": "uint256"
}
],
"name": "logDelegatorClaimedRewards",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "newDynasty",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "oldDynasty",
"type": "uint256"
}
],
"name": "logDynastyValueChange",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "exitEpoch",
"type": "uint256"
},
{
"internalType": "address",
"name": "signer",
"type": "address"
}
],
"name": "logJailed",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getAccountStateRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "accountStateRoot",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getCommittee",
"outputs": [
{
"internalType": "bytes",
"name": "committee",
"type": "bytes"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getEraSize",
"outputs": [
{
"internalType": "uint256",
"name": "eraSize",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "eraId",
"type": "uint256"
}
],
"name": "getEraStart",
"outputs": [
{
"internalType": "uint256",
"name": "startTimestamp",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "eraId",
"type": "uint256"
}
],
"name": "getEraValidatorRewardAccumulated",
"outputs": [
{
"internalType": "uint256",
"name": "rewardAccumulated",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getCurrentEraId",
"outputs": [
{
"internalType": "uint256",
"name": "eraId",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "eraId",
"type": "uint256"
}
],
"name": "getValidatorEraRewardAccumulated",
"outputs": [
{
"internalType": "uint256",
"name": "rewardAccumulated",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "validatorId",
"type": "uint256"
}
],
"name": "getValidatorLockup",
"outputs": [
{
"internalType": "uint256",
"name": "lockupDuration",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "lockupAmount",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "isOwner",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "lockTokens",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "unlockTokens",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "uint256","type": "uint256","name": "validatorId"
},
{
"internalType": "address","type": "address","name": "user"
},
{
"internalType": "uint256","type": "uint256","name": "rewards"
}
],
"name": "DelegatorClaimedRewards","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "address","type": "address","name": "user"
},
{
"internalType": "uint256","type": "uint256","name": "fee"
}
],
"name": "ClaimFee","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "uint256","type": "uint256","name": "newDynasty"
},
{
"internalType": "uint256","type": "uint256","name": "oldDynasty"
}
],
"name": "DynastyValueChange","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "uint256","type": "uint256","name": "validatorId"
},
{
"internalType": "uint256","type": "uint256","name": "amount"
},
{
"internalType": "uint256","type": "uint256","name": "totalAmount"
}
],
"name": "ClaimRewards","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "uint256","type": "uint256","name": "newValidatorId"
},
{
"internalType": "uint256","type": "uint256","name": "oldValidatorId"
},
{
"internalType": "uint256","type": "uint256","name": "amount"
}
],
"name": "ConfirmAuction","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "uint256","type": "uint256","name": "validatorId"
},
{
"internalType": "address","type": "address","name": "user"
},
{
"internalType": "uint256","type": "uint256","name": "amount"
}
],
"name": "DelegatorRestaked","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "uint256","type": "uint256","name": "validatorId"
},
{
"internalType": "address","type": "address","name": "user"
},
{
"internalType": "uint256","type": "uint256","name": "amount"
}
],
"name": "DelegatorUnstaked","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "uint256","type": "uint256","name": "validatorId"
},
{
"internalType": "uint256","type": "uint256","name": "exitEpoch"
},
{
"internalType": "address","type": "address","name": "signer"
}
],
"name": "Jailed","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "bytes32","type": "bytes32","name": "accountStateRoot"
}
],
"name": "NewAccountStateRoot","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "bytes32","type": "bytes32","name": "committeeStateRoot"
}
],
"name": "NewCommitteeStateRoot","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "uint256","type": "uint256","name": "eraSize"
}
],
"name": "NewEraSize","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "uint256","type": "uint256","name": "eraId"
},
{
"internalType": "uint256","type": "uint256","name": "startTimestamp"
}
],
"name": "NewEraStart","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "uint256","type": "uint256","name": "eraId"
},
{
"internalType": "uint256","type": "uint256","name": "rewardAccumulated"
}
],
"name": "NewEraValidatorRewardAccumulated","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "uint256","type": "uint256","name": "eraId"
},
{
"internalType": "uint256","type": "uint256","name": "rewardAccumulated"
}
],
"name": "NewValidatorEraRewardAccumulated","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "uint256","type": "uint256","name": "validatorId"
},
{
"internalType": "uint256","type": "uint256","name": "lockupDuration"
},
{
"internalType": "uint256","type": "uint256","name": "lockupAmount"
}
],
"name": "SetValidatorLockup","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "address","type": "address","name": "previousOwner"
}
],
"name": "OwnershipRenounced","type": "event"
},
{
"anonymous": false,
"inputs": [
{
"internalType": "address","type": "address","name": "previousOwner"
},
{
"internalType": "address","type": "address","name": "newOwner"
}
],
"name": "OwnershipTransferred","type": "event"
}
];
const contract = new web3.eth.Contract(contractABI, contractAddress);
async function fetchEventDataForValidator(validatorId) {
await sleep(5000);
try {
const events = await contract.getPastEvents('SignerChange', {
filter: { validatorId },
fromBlock: 'earliest',
toBlock: 'latest',
});
events.forEach((event) => {
const oldSigner = event.returnValues.oldSigner;
const newSigner = event.returnValues.newSigner;
console.log('Validator ID:', validatorId);
console.log('Old Signer:', oldSigner);
console.log('New Signer:', newSigner);
});
} catch (error) {
console.error('Error fetching event logs for Validator ID:', validatorId);
console.error(error);
}
}
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('Enter validator ID: ', (validatorId) => {
rl.close();
validatorId = parseInt(validatorId, 10);
if (!isNaN(validatorId)) {
fetchEventDataForValidator(validatorId);
} else {
console.error('Invalid input. Please enter a valid validator ID.');
}
});
Dependencies Installation:
Ensure that Node.js is installed on your system. If not, you can download it from nodejs.org. Navigate to the directory where you saved the script on your system using the terminal or command prompt. Web3.js Installation:
Execute the following command to install the Web3.js library:
npm install web3
Script Editing:
Open the script (your-script.js
) in a text editor. Replace 'https://your-rpc-ethereum' with the RPC URL of your Ethereum node.
In the terminal or command prompt, within the directory where the script is located, execute the following command:
node your-script.js
Make sure to replace your-script.js
with the actual name of your script file.
Note: that in the script, all events defined in the contract have been included, providing the flexibility to implement logic related to any specific event, not limited solely to SignerChange.
Last updated