Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
31

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 - transaction sequence number fr the sending account gasprice - price you are offering to pay startgas - maximum amount of gas allowed for the ...


26

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 existing unmined transaction's gas price. Increase your nonce to one higher than the unmined transaction. I have also been getting this error: "Transaction was ...


22

ethereumjs-tx is a library with this example: npm install ethereumjs-tx var Tx = require('ethereumjs-tx') var privateKey = new Buffer('e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109', 'hex') var rawTx = { nonce: '0x00', gasPrice: '0x09184e72a000', gasLimit: '0x2710', to: '0x0000000000000000000000000000000000000000', value: '...


14

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, this allows you to do it via GUI. Navigate to the "Offline Transaction" tab via your online computer. Here you will generate the current gas price and nonce. ...


13

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 raw bytes of a valid transaction, they can use sendRawTransaction. Otherwise, web3.js creates the signed transaction's bytes for you automatically as part of ...


13

In Go creating a signed transaction would look something like this: transaction := types.NewTransaction(nonce, recipient, value, gasLimit, gasPrice, input) signature, _ := crypto.Sign(transaction.SigHash().Bytes(), key) signed, _ := tx.WithSignature(signature) where key is a plain *ecdsa.PrivateKey. If you want to use Ethereum encrypted accounts, you could ...


13

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-decentralized-apps-with-ethereum-and-javascript/.) It uses web3.js and ethereumjs-tx: <!-- from https://github.com/ethereumjs/browser-builds/raw/master/dist/...


12

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-null if the transaction has been mined and included into a block. The call is documented in https://github.com/ethereum/wiki/wiki/JSON-RPC#...


12

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 sign transactions using the unofficial RPC method eth.signTransaction. You then take this method's output and stick it on a USB, move the contents to my other ...


12

Using Web3.js 1.0.0 encoded = contractInstance.methods.myMethod(params).encodeABI() var tx = { to : myContractAddress, data : encoded } web3.eth.accounts.signTransaction(tx, privateKey).then(signed => { web3.eth.sendSignedTransaction(signed.rawTransaction).on('receipt', console.log) });


11

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 algorithm into a sequence of bytes. This sequence is called a raw transaction. Basically a raw transaction is a machine representation of a transaction, with the ...


11

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: 0xf86c258502540be40083035b609482e041e84074fc5f5947d4d27e3c44f824b7a1a187b1a2bc2ec500008078a04a7db627266fa9a4116e3f6b33f5d245db40983234eb356261f36808909d2848a0166fa098a2ce3bda87af6000ed0083e3bf7cc31c6686b670bd85cbc6da2d6e85 Hashed ...


10

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, https://github.com/ethereumjs/ethereumjs-tx and https://github.com/SilentCicero/ethereumjs-accounts, that can be used. See Create and sign OFFLINE raw ...


10

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 version of geth, it has two extra txpool API endpoint (txpool.content and txpool.inspect) that allows you to list the contents of pending and queue. My guess is ...


9

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.js API into the browser context, and allow you to use its methods for querying the blockchain, and submitting transactions for user signing & submitting to ...


9

As mentioned in the comments, add a 0x to your serializedTx.toString('hex').


8

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, you cannot set it. Geth does not set it. (Since the signature that is also included is based on it). Not as far as I know.


8

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 libs.pyethereum.ethereum import utils # Create the priv keys and addresses. Addresses are returned in bytearray key = utils.sha3("this is an insecure ...


8

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 Transaction The error message implies that you're trying to replace a pending transaction. That's because the raw transaction you're trying to send has the ...


7

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.signTransaction(). // var accounts = new Accounts('ws://localhost:8546'); var accounts = new Accounts(); // if nonce, chainId, gas and gasPrice is given it returns ...


7

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. You can also see it in the source code: https://github.com/ethereum/go-ethereum/blob/ca64a122d33008c155c35a9d0e78cfbcafb1820a/internal/web3ext/web3ext.go (look ...


7

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 specifically adding nonce of "0xa"


7

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", // 10000000000000 Also, the nonce may need to be converted to hexadecimal. The getTransactionCount method returns a javascript number, so you might need to convert ...


6

Here's some working code using ethereumjs-tx: const EthereumTx = require('ethereumjs-tx'); const raw = '...


5

This can be done using EthereumJS: a collection of libraries and utilities for Ethereum. https://github.com/ethereumjs First, obtain the raw encoding of the block containing your target transaction. This can be done on live.ether.camp. Alternatively, if you don't want to copy from live.ether.camp, you can recover the raw block encodings by loading your ...


5

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 try: return { 'error':False, 'sign':rlp.encode(transactions.Transaction(nonce, gasPrice, gas, to, value, data).sign(privkey)).encode('hex') } ...


5

SMS supports multi-part messages. Is that not reliable in the countries you are targeting? Assuming you are bound to the plain old SMS protocol, let's see what can be done. This is a simple send value transaction: ...


5

I believe you need to use canonical hex representation: eth.sendRawTransaction('**0x**f87a831001888504a817c800830493e09454a25919a915bbaeb58a96679428f80d733af89392313030303030303030303030303030303030801ca0ecd622603d87d290b7440a8a03413d865dd67783e90cde0ef33d3f5752888ffda031adeee357777c7c39f3edb8920c91aec0cced05ad429d8aa4be627604bd820b');


5

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 of the new contract. Probably the main reason for this behavior is to avoid conflicts between addresses. Someone should not be able to overwrite a contract ...


5

Can you try printing out the raw serialized transaction and sending it to ropsten directly with CURL? https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendrawtransaction Do you get a txid back?


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