Skip to main content
57 votes
Accepted

error: replacement transaction underpriced

I have been running into this issue as well. The network thinks you are trying to replace an existing unmined transaction. There are two ways to avoid this: Adding a gas price %10 higher than the ...
M1Reeder's user avatar
  • 710
24 votes

error: replacement transaction underpriced

Define the Goal Do you want to: Send a new transaction, after all your previous transactions have completed, or... Replace a pending (unmined) transaction, with the new raw transaction. Send a New ...
carver's user avatar
  • 6,381
19 votes
Accepted

How to properly create a raw transaction and sign it using web3 in browser

Below is working code that calls "increment" on https://programtheblockchain.com/dapps/counter. (More info about that sample here: https://programtheblockchain.com/posts/2017/12/13/building-...
user19510's user avatar
  • 28.1k
18 votes

How to properly create a raw transaction and sign it using web3 in browser

Using Web3.js 1.0.0 encoded = contractInstance.methods.myMethod(params).encodeABI() var tx = { to : myContractAddress, data : encoded } web3.eth.accounts.signTransaction(tx, privateKey)....
biplavo's user avatar
  • 934
16 votes
Accepted

Difference between transactions and raw transactions in web3.js

All transactions need to be signed. Otherwise they are considered invalid transactions and will not be included in the blockchain. A raw transaction is a transaction in raw bytes. If one has the ...
eth's user avatar
  • 86.3k
16 votes
Accepted

How to get raw ethereum transaction hash

Ok, so asked it a couple of minutes too soon. As the name implies it's a hash, hash of what? Hash of your raw hex in example: ...
Kristaps's user avatar
  • 359
13 votes
Accepted

What is a "raw transaction" and what is it used for?

A transaction as defined in the Yellow Paper section 4.3 it consist of several fields (like gasPrice, value, etc). To store them in the blockchain they are encoded using the Recursive Length Prefix ...
Ismael's user avatar
  • 30.3k
11 votes

Create and sign OFFLINE raw transactions?

You can use Web3. var Accounts = require('web3-eth-accounts'); // Passing in the eth or web3 package is necessary to allow retrieving chainId, gasPrice and nonce automatically // for accounts....
artamonovdev's user avatar
10 votes
Accepted

Get raw transaction from hash

There is eth.getRawTransaction(<txhash>) now. Edit: Please check that you're using an up-to-date version of geth. It's part of the current release (v.1.8.6) and was introduced some time ago. ...
Pold's user avatar
  • 293
10 votes
Accepted

Sign a raw transaction with Metamask or Mist

In Ethereum, a "raw transaction" is one that has been signed, so you don't sign raw transactions, you sign transactions, and you submit them to the blockchain. Both Mist and MetaMask inject the web3....
DanF's user avatar
  • 2,626
10 votes
Accepted

web3.eth.sendRawTransaction: cannot unmarshal hex string without 0x prefix

As mentioned in the comments, add a 0x to your serializedTx.toString('hex').
Joël's user avatar
  • 1,720
10 votes
Accepted

How to create a RawTransaction for contract interaction Web3j

Let's take for example the following simple storage contract: pragma solidity ^0.5.6; contract SimpleStorage { uint storedData; function set(uint x) public { storedData = x; } ...
Greg Jeanmart's user avatar
9 votes

Get the balance of an ERC20 token at an Ethereum address

You are nearly there with your payload, only the function ID for balanceOf is wrong. Calculating the Function Selector From the Solidity docs: The first four bytes of the call data for a function ...
carver's user avatar
  • 6,381
9 votes

When are “pending” transactions dropped from the blockchain?

All transactions are kept in the Mempool a term borrowed from Bitcoin. You can see all the current pending transactions here: Pending Transactions There's a limit to the size of the Mempool and once ...
I.B's user avatar
  • 615
9 votes
Accepted

How to construct a raw Ethereum transaction from transaction data

A raw transaction is just all the transaction parameters encoded in the RLP format. A raw transaction consists of (in this order): Nonce; Gas price; Gas limit; To address; Value; Data. You don't ...
Morten's user avatar
  • 6,052
8 votes
Accepted

Can I deploy a contract to an arbitrary address that I choose?

Contracts can't be deployed to an arbitrary user specified address. New contracts are created by the CREATE opcode in the EVM which implements the rules and doesn't have a parameter for the address ...
eth's user avatar
  • 86.3k
8 votes
Accepted

Can not send eth on Ropsten using Infura node

This looks mostly correct, but there are a couple optional tx parameters that might make the difference: // EIP 155 chainId - mainnet: 1, ropsten: 3 chainId: 3, gasPrice: "0x9184e72a000", // ...
DanF's user avatar
  • 2,626
8 votes

Given only a raw transaction, how can I determine the from address that signed it?

Here's some working code using ethereumjs-tx: const EthereumTx = require('ethereumjs-tx').Transaction; const raw = '...
user19510's user avatar
  • 28.1k
8 votes

Building a raw contract transaction with ethers.js

You can use the populateTransaction mechanism documented here: https://docs.ethers.io/v5/api/contract/contract/ So specifically, that'd be: const data = await myContract.populateTransaction.myFunction(...
KevinBrownTech's user avatar
7 votes
Accepted

Can't Broadcast ethereum transaction, what's wrong with this transaction?

The problem I found was that Parity had skipped a nonce, so that the next nonce was actually "0xa", but Parity decided to put "0xb" into the transaction. To resolve this I created another transaction ...
Bitcoin Bob's user avatar
7 votes

How to decode a raw transaction in Python?

Previous answer is great and works but if you want a shorter code using only 3rd libraries, you can do this: import rlp from eth_typing import HexStr from eth_utils import to_bytes from ethereum....
noleto's user avatar
  • 171
6 votes

Get raw transaction from hash

There is an "undocumented" method eth_getRawTransactionByHash from JSON-RPC curl -H "Content-Type: application/json" -X POST --data \ '{"jsonrpc":"2.0","method":"eth_getRawTransactionByHash","params":...
mishabunte's user avatar
6 votes

Error: Known Transaction

if your problem is the Known Transaction Error originating from the same use of nonce from getTransactionCount, you can use the transaction count with the pending transaction count for your nonce. ...
Marci Banez's user avatar
6 votes
Accepted

Signing a raw transaction in Go

You can use two methods to obtain the raw transation RLP Get the String() of the signed transaction. You can invoke it directly, or let the fmt library do it for you: my_string_var = signed_tx....
hhh's user avatar
  • 2,381
6 votes

How to decode input data from tx using python3?

If you know the contract ABI, call data could be decoded using pyethereum: from ethereum.abi import ( decode_abi, normalize_name as normalize_abi_method_name, method_id as ...
xuhcc's user avatar
  • 191
6 votes
Accepted

What is chainID? Raw transaction from myEther wallet

The chainid was added about 1 year ago in order to prevent replay attacks across channels. This was due to the ETH / ETC fork, but also applies to testnet and alternate chains (like Expanse). Here you ...
tayvano's user avatar
  • 16k
6 votes
Accepted

send raw transaction without knowing nonce

The nonce is part of the transaction data, so it contributes to the transaction hash, which is what you sign with the private key. So you need to know the nonce you want to use before signing the ...
user19510's user avatar
  • 28.1k
6 votes
Accepted

How to decode a raw transaction in Python?

Code: from dataclasses import asdict, dataclass from pprint import pprint from typing import Optional import rlp from eth_typing import HexStr from eth_utils import keccak, to_bytes from rlp.sedes ...
Max Block's user avatar
  • 307
5 votes

Create and sign OFFLINE raw transactions?

I wrote an complete Python code. Feel free to use: def signTransaction(to, value, privkey, nonce=0, gasPrice=20000000000, gas=21000, data=""): from ethereum import transactions import rlp ...
iFA88's user avatar
  • 51

Only top scored, non community-wiki answers of a minimum length are eligible