Sending a Transaction
To send a transaction, you must construct a valid transaction object and then prompt the user to sign the transaction with their private key.
Direct Sending
Triggering this directly would look make use of the provider request
function and look like this:
However, there are several other parts of a transaction object that might need to be specfied, and therefore it is suggested to make use of a web3 library that abstracts away a lot of this complexity, like ethers.js
Using Ethers.js
Below is a code example that builds out a valid transaction object and prompts the transaction to send with permission from the signer, utilizing ethers.js
You'll notice a lot more structure with the parameters needed to invoke signer.sendTransaction
. Due to the abstraction and wide use of libraries like ethers, we recommend this method when constructing your evm transactions.
Last updated