The following readme describes all the functions and their parameters exposed by the utils
class of the K2 SDK.
This function can be used to append 0x
towards the start of a string to convert it into a hex string accepted by the contracts. If the input string already contains the 0x
, the function will return the string as is.
data: string which needs to be appended by 0x
Returns hex string
This function removes 0x
from the beginning of a string. If the input string doesn’t contain 0x
, it will return the string as is.
data: string to remove 0x
from
Returns string without 0x
in the beginning.
This function can be used to generate a liveness reports of the software being run.
middlewareAPI: API endpoint of the middleware
Returns a liveness report. Here’s a sample liveness report:
This function can be used to get the info from the middleware endpoint.
middlewareAPI: API endpoint of the middleware
The function returns info related to the middleware API. Here’s an example of the info:
Once the liveness or the corruption report has been generated, it needs to be verified before submitting it to the reporter registry. To verify the report, verifyReport
function should be used.
middlewareAPI: API endpoint of the middleware
report: Liveness or the corruption report returned by the respective function
The function returns a verified report which contains the liveness report along with a signature valid for 20 minutes. Here’s how a verified report looks like:
This function can be used to batch verify effective balance of a list of BLS public keys.
blsPublicKeys: List of BLS public keys in string format
effectiveBalances: List of effective balance in string corresponding to each BLS public key
The function returns a list of verified effective balance report after it has been successfully verified and error otherwise.
Allows to read batch values from a contract in a single RPC call.
targetContract: Address of the target contract in string format
allowFailure: Boolean. Set to true
to throw error if any one value is rejected by the contract
calldata: List of calldata in string
Returns a list of response for each call data in the format:
The result will have to be decoded to correctly get all the values.
Get effective balance of a BLS public key from the consensus layer.
beaconNodeUrl: Beacon node URL string
blsPublicKey: BLS public key in string format to get effective balance of
Effective balance in numbers
Generate corruption report from the data received from middleware API endpoint.
middlewareAPI: API endpoint of the middleware
eventData: event data of the format CorruptionEventDataT
message: string message which needs to be mentioned in the report. Default value: ''
debtorOverride: optional debtor address. Can be left null
for the function to fetch debtor address from the middlewareAPI
Returns corruption report of the format:
Claim effective balance for all the BLS public keys delegated by the user.
beaconNodeUrl: Beacon node URL in string
userAddress: user address in string
Transaction hash
Preview claimable effective balance for all the BLS public keys delegated by the user.
userAddress: user address in string
List of claimable kETH in Big Numbers
Get a list of BLS public keys delegated by a node operator.
nodeRunnerAddress: Address of the node runner in string
List of BLS public keys
List of all the delegated BLS public keys in the K2 protocol.
List of BLS public keys
The following readme describes all the functions and their parameters exposed by the utils
class of the K2 SDK.
This function can be used to append 0x
towards the start of a string to convert it into a hex string accepted by the contracts. If the input string already contains the 0x
, the function will return the string as is.
data: string which needs to be appended by 0x
Returns hex string
This function removes 0x
from the beginning of a string. If the input string doesn’t contain 0x
, it will return the string as is.
data: string to remove 0x
from
Returns string without 0x
in the beginning.
This function can be used to generate a liveness reports of the software being run.
middlewareAPI: API endpoint of the middleware
Returns a liveness report. Here’s a sample liveness report:
This function can be used to get the info from the middleware endpoint.
middlewareAPI: API endpoint of the middleware
The function returns info related to the middleware API. Here’s an example of the info:
Once the liveness or the corruption report has been generated, it needs to be verified before submitting it to the reporter registry. To verify the report, verifyReport
function should be used.
middlewareAPI: API endpoint of the middleware
report: Liveness or the corruption report returned by the respective function
The function returns a verified report which contains the liveness report along with a signature valid for 20 minutes. Here’s how a verified report looks like:
This function can be used to batch verify effective balance of a list of BLS public keys.
blsPublicKeys: List of BLS public keys in string format
effectiveBalances: List of effective balance in string corresponding to each BLS public key
The function returns a list of verified effective balance report after it has been successfully verified and error otherwise.
Allows to read batch values from a contract in a single RPC call.
targetContract: Address of the target contract in string format
allowFailure: Boolean. Set to true
to throw error if any one value is rejected by the contract
calldata: List of calldata in string
Returns a list of response for each call data in the format:
The result will have to be decoded to correctly get all the values.
Get effective balance of a BLS public key from the consensus layer.
beaconNodeUrl: Beacon node URL string
blsPublicKey: BLS public key in string format to get effective balance of
Effective balance in numbers
Generate corruption report from the data received from middleware API endpoint.
middlewareAPI: API endpoint of the middleware
eventData: event data of the format CorruptionEventDataT
message: string message which needs to be mentioned in the report. Default value: ''
debtorOverride: optional debtor address. Can be left null
for the function to fetch debtor address from the middlewareAPI
Returns corruption report of the format:
Claim effective balance for all the BLS public keys delegated by the user.
beaconNodeUrl: Beacon node URL in string
userAddress: user address in string
Transaction hash
Preview claimable effective balance for all the BLS public keys delegated by the user.
userAddress: user address in string
List of claimable kETH in Big Numbers
Get a list of BLS public keys delegated by a node operator.
nodeRunnerAddress: Address of the node runner in string
List of BLS public keys
List of all the delegated BLS public keys in the K2 protocol.
List of BLS public keys