Skip to main content

balanceReport sub-class

The following readme describes all the functions and their parameters exposed by the balanceReport sub-class of the Stakehouse SDK.

getFinalisedEpochReport function

This function accepts a beacon node URL and BLS Public Key to return the most recent finalised epoch report for a validator. This report can then be authenticated using the authenticateReport function and the resulting output can be fed to the reportBalanceIncrease (and many more functions) to submit updated ETH balance to the Balance Reporter Smart Contract.

Input Parameter

beaconNodeURL: URL of the beacon chain node,
blsPublicKey: Validator's BLS Public key

Using getFinalisedEpochReport function

await sdk.balanceReport.getFinalisedEpochReport(beaconNodeURL, blsPublicKey);

Return Parameter

// This is what a finalised epoch report looks like
{
"blsPublicKey":"a97f0308ffffd1d253f35ef4d8309059b7d89fd53...",
"withdrawalCredentials":"010000000000000000000000f847b446...",
"slashed":false,
"activeBalance":"32042871296",
"effectiveBalance":"32000000000",
"exitEpoch":"18446744073709551615",
"activationEpoch":"63601",
"withdrawalEpoch":"18446744073709551615",
"currentCheckpointEpoch":66805
}

authenticateReport function

This function accepts a finalised Beacon Chain report from the user and returns Deposit Router response data if the authentication was successful, otherwise an error statement is returned.

Input Parameter

finalisedBeaconChainReport:

// This is just a sample Finalised Beacon Chain Report
{
"blsPublicKey":"a97f0308ffffd1d253f35ef4d8309059b7d89fd53...",
"withdrawalCredentials":"010000000000000000000000f847b446...",
"slashed":false,
"activeBalance":"32042871296",
"effectiveBalance":"32000000000",
"exitEpoch":"18446744073709551615",
"activationEpoch":"63601",
"withdrawalEpoch":"18446744073709551615",
"currentCheckpointEpoch":66805
}

Using authenticateReport function

await sdk.balanceReport.authenticateReport(finalisedBeaconChainReport);

Return Parameter

If the authentication was successful, then a Deposit Router response is returned. Here is how it looks like:

{
report: {
blsPublicKey: 'a97f0308ffffd1d253f35ef4d8309059b7d89f...',
withdrawalCredentials: '010000000000000000000000f847b...',
slashed: false,
activeBalance: '32042855400',
effectiveBalance: '32000000000',
exitEpoch: '18446744073709551615',
activationEpoch: '63601',
withdrawalEpoch: '18446744073709551615',
currentCheckpointEpoch: 66804
},
deadline: 6199503,
v: 27,
r: '88bf72df9e2b8e4588e26c4a50f4bfaf3746a57b52f50ee61f61...',
s: '129474d568b986e7747b46e63438ab181c861d72831b3a674cbb...'
}

Otherwise, an error response is returned for eg. 'Error: Failed to validate against multiple beacon nodes' error will appear when the deposit router receives data from nodes that are out of sync.