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
29 votes
Accepted

Create and sign OFFLINE raw transactions?

ethereumjs-tx is a library with this example: npm install ethereumjs-tx const Tx = require('ethereumjs-tx').Transaction var privateKey = new Buffer('...
eth's user avatar
  • 86k
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
  • 86k
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
15 votes
Accepted

How to get the transaction confirmations using the JSON RPC

When you send a transaction, you will receive back a transaction hash. Use the command getTransactionByHash({transaction hash}) to retrieve the transaction details. Your blockNumber should be non-...
BokkyPooBah's user avatar
  • 40.3k
15 votes
Accepted

Is there any safe way to send money from a cold wallet, using an untrusted computer?

We at MyEtherWallet.com implemented an offline transaction tool to do exactly this. While most people who are cold-storage fanatics know command line and the inner-workings of gas price and nonce, ...
tayvano's user avatar
  • 16k
13 votes

Create and sign OFFLINE raw transactions?

In Go creating a signed transaction would look something like this: transaction := types.NewTransaction(nonce, recipient, value, gasLimit, gasPrice, input) signature, _ := crypto.Sign(transaction....
Péter Szilágyi's user avatar
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.5k
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
11 votes

Using web3 to sign a transaction without connecting to geth

Not in web3.js. EDIT: As answered by @Andromelus, web3js 1.0 can do it with the following function: web3.eth.accounts.signTransaction(tx, privateKey [, callback]); There are other libraries such as, ...
eth's user avatar
  • 86k
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

How do I set the nonce for raw transactions?

A raw transaction is the RLP encoded value of a signed transaction, i.e. everything included as defined by the yellow paper page 4, section 4.2 Nonces must already be included in the raw transaction, ...
Péter Szilágyi's user avatar
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,027
8 votes

Create and sign OFFLINE raw transactions?

I found a way using the pyethereum lib. BTW, this lib has little maintenance and doesn't build in most OS's. Here's the sample code for that: from libs.pyethereum.ethereum import transactions from ...
Nico's user avatar
  • 807
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
  • 86k
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

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