You can subscribe to ValidatorEpochInfoEventV2
events
const client = new SuiClient({
url: 'https://fullnode.mainnet.sui.io'
});
export const subscribeEvent = async (handler: (e: any) => void) => {
await client.subscribeEvent({
filter: {
MoveEventType: '0x3::validator_set::ValidatorEpochInfoEventV2'
},
onMessage: (event: SuiEvent) => {
console.log('Event Occured:', JSON.stringify(event, null, 2));
},
});
}
Also you can query for old events directly (WARNING: Results are paginated ):
async function getEpochInfoEvents() {
const eventsResponse = await client.queryEvents({
query: {
MoveEventType: '0x3::validator_set::ValidatorEpochInfoEventV2'
},
limit: 50,
cursor: null,
order: 'ascending'
});
console.log('eventsResponse = ', eventsResponse.data);
}
getEpochInfoEvents();
Response:
{
id: {
txDigest: '8eBMXpC8Np7RNDwwiGwSmeev1cSoc7w3fPXdikhH7RZo',
eventSeq: '48'
},
packageId: '0x0000000000000000000000000000000000000000000000000000000000000003',
transactionModule: 'sui_system',
sender: '0x0000000000000000000000000000000000000000000000000000000000000000',
type: '0x3::validator_set::ValidatorEpochInfoEventV2',
parsedJson: {
commission_rate: '200',
epoch: '1',
pool_staking_reward: '0',
pool_token_exchange_rate: [Object],
reference_gas_survey_quote: '1000',
stake: '20000000000000000',
storage_fund_staking_reward: '0',
tallying_rule_global_score: '1',
tallying_rule_reporters: [],
validator_address: '0xa528acf0c239c28985da3170870629eb58dd9fb2683548317ce0a218427abb8d',
voting_power: '43'
},
bcs: 'q4ijhZmHtJ9JUVUtkz95LTWyCKykkMPBsMub3hLV8TkRaEPTjfELpw9YrjMF3Xofhk1jRvBRsaQ2eL6ZMAPDajmd7Zo9pfhT5wS9kV9ougR3b
T8ixPo8Jafr6fcZ7B5aoyegNFFHMXaHKE6teRsY6vEb',
timestampMs: '1690231065905'
},
{
id: {
txDigest: '8eBMXpC8Np7RNDwwiGwSmeev1cSoc7w3fPXdikhH7RZo',
eventSeq: '49'
},
packageId: '0x0000000000000000000000000000000000000000000000000000000000000003',
transactionModule: 'sui_system',
sender: '0x0000000000000000000000000000000000000000000000000000000000000000',
type: '0x3::validator_set::ValidatorEpochInfoEventV2',
parsedJson: {
commission_rate: '200',
epoch: '1',
pool_staking_reward: '0',
pool_token_exchange_rate: [Object],
reference_gas_survey_quote: '1000',
stake: '20000000000000000',
storage_fund_staking_reward: '0',
tallying_rule_global_score: '1',
tallying_rule_reporters: [],
validator_address: '0x9b8b11c9b2336d35f2db8d5318ff32de51b85857f0e53a5c31242cf3797f4be4',
voting_power: '43'
},
bcs: 'q4ijhZmHtHxWTMkiWsCbNhvPuQ8TmXjW1Qxc52yvh3XUsRBdBtzMGyfwaZyT3RKDhQqf69iSGZwAgW6w6SQegX6UeoycjLQYUKqSqzG3m32Rj
HV7tE1mMVntarw4h5vpU74XPVRZ7548QhhJcTndFhSf',
timestampMs: '1690231065905'
}
...
]