Reading contract state
The recommended way to read the contract state is to use the readContract
function and pass the Solidity method signature and the params. This is type-safe based on the Solidity method signature you define. You can get your desired contract method signature from the solidity code directly.
This will execute the read immediately and return the result from the blockchain.
The recommended way to read the contract events is to use the getContractEvents
function and passing a prepared event with the Solidity event signature and the params. This is type-safe based on the Solidity event signature you define. You can get your desired contract event signature from the solidity code directly.
Using the CLI, you can generate optimized functions for all the possible calls to a contract. This saves you time and precomputes all the necessary encoding.
Read more on how to generate extension functions using the CLI.