50
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 ...
39
votes
Accepted
What is the ethereum transaction data structure?
An Ethereum transaction - as in, what you pass to sendRawTransaction() - consists of the following fields, in order and RLP-encoded (note that the field names are not part of the encoded data):
nonce ...
28
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♦
- 83.3k
23
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 ...
18
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-...
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)....
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♦
- 83.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:
...
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, ...
14
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-...
14
votes
Accepted
What is the networkid and chain id of truffle cli?
You can get both using the web3 instance of web3.js:
const networkId = await web3.eth.net.getId();
const chainId = await web3.eth.getChainId();
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....
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 ...
12
votes
Is there any safe way to send money from a cold wallet, using an untrusted computer?
I've set something like this up myself. I've bought a silly simple laptop which runs a node which for obvious reasons it isn't connects to the network and has never been online. I use this device to ...
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♦
- 83.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....
10
votes
Accepted
sendRawTransaction results in queued TXs
If the transaction is queued but not executable, that means that there's a nonce gap between your latest executed transaction and the next in line that's waiting to run.
If you pull in a develop ...
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, ...
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. ...
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....
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').
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;
}
...
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 ...
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 ...
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 ...
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", // ...
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 = '...
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 ...
7
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♦
- 83.3k
7
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(...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
raw-transaction × 257transactions × 96
web3js × 54
go-ethereum × 35
signature × 28
sendrawtransaction × 15
nonce × 13
solidity × 12
json-rpc × 12
ethereumjs-tx × 12
gas × 10
contract-invocation × 10
javascript × 10
web3.py × 10
ether × 9
ethereumjs × 9
rlp × 9
tokens × 8
python × 8
abi × 8
metamask × 7
pending-transactions × 7
ethers.js × 7
hash × 7
openethereum × 7