Read
This is a generic method for invoking JSON RPC's eth_call
with Ethers.js. Use this method to execute a smart contract's constant or non-constant member without using gas. This is a read-only method intended to read a value or test a transaction for valid parameters. It does not create a transaction on the block chain.
address
(string) The Ethereum address the transaction is directed to.method
(string) The smart contract member in which to invoke.[parameters]
(any[]) Parameters of the method to invoke.[options]
(CallOptions) Options to set foreth_call
, optional ABI (as JSON object), and Ethers.js method overrides. The ABI can be a string of the single intended method, an array of many methods, or a JSON object of the ABI generated by a Solidity compiler.RETURN
(Promise<any>) Return value of the invoked smart contract member or an error object if the call failed.
const sEthAddress = Belugas.util.getAddress(Belugas.aBNB);
(async function() {
const srpb = await Belugas.eth.read(
sEthAddress,
'function supplyRatePerBlock() returns (uint256)',
// [], // [optional] parameters
// {} // [optional] call options, provider, network, plus Ethers.js "overrides"
);
console.log('aBNB market supply rate per block:', srpb.toString());
})().catch(console.error);
Last updated