Skip to main content
MetaMask
Restricted
Multichain API

eth_sendTransaction

Summary: Initiates a new transaction.

Creates a new wallet confirmation to make an Ethereum transaction from the user's account. This method requires that the user has granted permission to interact with their account first, so make sure to call eth_requestAccounts (recommended) or wallet_requestPermissions first.

Parameters

Transaction
object
required

The parameters to customize a transaction. If a to address is not provided, the transaction is assumed to be a contract creation transaction, and the data field is used as the contract initialization code. gasPrice cannot be used together with maxPriorityFeePerGas and maxFeePerGas.

to
string

The recipient's address.

Pattern: ^0x[0-9a-fA-F]{40}$

from
string

The sender's address.

Pattern: ^0x[0-9a-fA-F]{40}$

gas
string

The maximum amount of gas the transaction is allowed to use.

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

value
string

The amount to transfer in wei.

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

data
string

The data to include in the transaction. Used for contract creation transactions.

Pattern: ^0x[0-9a-f]*$

gasPrice
string

The gas price the sender is willing to pay to miners in wei. Used in pre-1559 transactions.

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

maxPriorityFeePerGas
string

Maximum fee per gas the sender is willing to pay to miners in wei. Used in 1559 transactions.

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

maxFeePerGas
string

The maximum total fee per gas the sender is willing to pay (includes the network / base fee and miner / priority fee) in wei. Used in 1559 transactions.

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Returns

Transaction hash
string

The transaction hash of the sent transaction.

Pattern: ^0x[0-9a-f]{64}$

Errors

Code
Message
4100
The requested account and/or method has not been authorized by the user.
Customize request
Parameter
Value
string
string
string
string
string
string
string
string

Connect your MetaMask wallet to run requests successfully.

Request

await window.ethereum.request({
"method": "eth_sendTransaction",
"params": [
{
to: "0x4B0897b0513FdBeEc7C469D9aF4fA6C0752aBea7",
from: "0xDeaDbeefdEAdbeefdEadbEEFdeadbeefDEADbEEF",
gas: "0x76c0",
value: "0x8ac7230489e80000",
data: "0x",
gasPrice: "0x4a817c800"
}
],
});

Example response

"0x4e306b5a5a37532e1734503f7d2427a86f2c992fbe471f5be403b9f734e667c8"