eth_sendTransaction
Creates new message call transaction or a contract creation, if the data field contains code.
Params
Transaction:Object. A standard Ethereum transaction object. Only the following properties will be referenced:to:string. The destination address of the message.data:string(optional). Either a byte string containing the associated data of the message, or in the case of a contract-creation transaction, the initialisation code.value:string(optional). The value transferred for the transaction in wei, encoded as a hex string.
This method does not support the gas, gasPrice, maxPriorityFeePerGas, or maxFeePerGas properties as the relayer abstracts these away from the user.
Additionally, the from property is not supported as the user's Passport wallet address is used instead.
Result
TransactionHash:string. A promise that resolves with a 32-byte hex string containing the transaction hash.
Method Specific Errors
| Error Code | Message | Resolution |
|---|---|---|
| -32602 | eth_sendTransaction requires a "to" field | Ensure that a valid to property has been specified |
| 4100 | Unauthorised - call eth_requestAccounts first | Ensure that eth_requestAccounts is called before calling eth_sendTransaction |
Example
const transactionHash = await provider.request({
method: 'eth_sendTransaction',
params: [
{
to: '0x...',
data: '0x...',
value: '0x...'
}
]
});
console.log(transactionHash); // ['0x...']