Transactions
Transactions are the primary way to read and write to the blockchain.
Reading contract state
The recommended way to read 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.
Preparing a contract call
The recommended way to prepare a contract call is to 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 return a prepared transaction object that is ready to be sent to the blockchain and can be acted on in various ways.
Preparing a raw transaction
You can also create a raw transaction directly. This is useful when you want to send ether to an address for example, or when you already have encoded data.
Acting on a prepared transaction
Transactions have a variety of actions that can be called on them, in all cases this is done by passing the transaction to the various action functions.
Send the prepared transaction to the blockchain. Sending a transaction requires a wallet.
See Wallets for more information on how to create a wallet.
Other ways to prepare a transaction
There are 3 other ways to prepare a contract call, all of these return the same transaction object.