useEtherspotTransactions()
estimate()
Any transaction that is intended to be sent to the blockchain must be estimated first. The estimation function performs several checks including cost estimation and transaction validity. This method must always be called before we send, otherwise the send method will return an error.
Whenever you add, edit or remove an EtherspotBatches, EtherspotBatch or EtherspotTransaction component - call the estimate hook. You simply need to import the hook and call the function as shown below.
import {
useEtherspotTransactions,
} from '@etherspot/transaction-kit';
// Later in the main component function...
const { estimate } = useEtherspotTransactions();
// And when you're ready to perform the estimate...
estimate(); // This is also a Promise
// Now your transactions are ready to send!
send()
The send function simply sends all the EtherspotBatches, which contain all EtherspotBatch and EtherspotTransaction components to the blockchain via the Etherspot platform.
You must always estimate before sending. Estimating first performs important transaction cost calculations that are required before sending.
Whenever you are ready to send your transaction to the blockchain, you simply need to call send() as shown below.
import {
useEtherspotTransactions,
} from '@etherspot/transaction-kit';
// Later in the main component function...
const { send } = useEtherspotTransactions();
// And when you're ready to end your transaction(s)...
send(); // This is also a Promise
// Your transactions are now being sent to the blockchain