eth_sendRawTransaction - Ethereum
Creates a new message call transaction or a contract creation for signed transactions.
Alchemy does not store keys, so transactions sent via Alchemy must be signed ahead of time using another provider like ethers (via eth_signTransaction) and sent with eth_sendRawTransaction.

Parameters

DATA, The signed transaction data.
1
params: ["0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"]
Copied!

Returns

DATA, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.
Use eth_getTransactionReceipt to get the contract address after the transaction was mined when you created a contract.
Example
Note: Since eth_sendRawTransaction is a request used for writing to the blockchain and changes its state, it is impossible to execute the same request twice. This means if you were to copy the example given below you will not get the expected response.
Request
alchemyweb3.js
ethers.js
web3.py
Curl
Postman
1
// Installation instructions: https://github.com/alchemyplatform/alchemy-web3
2
3
async function main() {
4
// Import the AlchemyWeb3 library. Filepath to functions:
5
// /@alch/alchemy-web3/dist/alchemyWeb3.js
6
const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
7
8
// Replace with your Alchemy API key:
9
const apiKey = "demo";
10
11
// Initialize an alchemy-web3 instance:
12
const web3 = createAlchemyWeb3(
13
`https://eth-mainnet.g.alchemy.com/v2/${apiKey}`);
14
15
// Query the blockchain (replace example parameters)
16
const hash = await web3.eth.sendRawTransaction({
17
signed_data: '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675',
18
});
19
20
// Print the output to console
21
console.log(hash);
22
}
23
24
main();
Copied!
1
// Installation instructions: https://docs.ethers.io/v5/getting-started/#installing
2
3
async function main() {
4
const { ethers } = require("ethers");
5
6
// Replace with your Alchemy API key:
7
const apiKey = "demo";
8
9
// Initialize an ethers instance
10
const provider = new ethers.providers.AlchemyProvider("homestead", apiKey);
11
12
// Query the blockchain (replace example parameters)
13
const hash = await provider.sendRawTransaction({
14
signed_data: '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675',
15
});
16
17
// Print the output to console
18
console.log(hash);
19
}
20
21
main()
Copied!
1
# Installation Instructions: https://web3py.readthedocs.io/en/latest/quickstart.html#installation
2
3
from web3 import Web3, HTTPProvider
4
5
#Replace with your Alchemy API key:
6
apiKey = "demo"
7
8
# Initialize a Web3.py instance
9
web3 = Web3(Web3.HTTPProvider('https://eth-mainnet.alchemyapi.io/v2/'+apiKey))
10
11
# Query the blockchain (replace example parameters)
12
txnhash = web3.eth.send_raw_transaction({
13
signed_txn.rawTransaction: "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
14
})
15
16
# Print the output to console
17
print(txnhash)
Copied!
1
curl https://eth-mainnet.alchemyapi.io/v2/your-api-key \
2
-X POST \
3
-H "Content-Type: application/json" \
4
-d '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"],"id":1}'
Copied!
1
URL: https://eth-mainnet.alchemyapi.io/v2/your-api-key
2
RequestType: POST
3
Body:
4
{
5
"jsonrpc":"2.0",
6
"method":"eth_sendRawTransaction",
7
"params":["0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"],
8
"id":1
9
}
Copied!
Result
1
{
2
"id":1,
3
"jsonrpc": "2.0",
4
"result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
5
}
6
7
Copied!
Common Error Code: -32000
"transaction underpriced"
  • transaction was sent with too low gas. Re-send the transaction with higher gas
Ethereum API
Alchemy Documentation
Copy link