ethereumjs / ethereumjs-tx

Project is in active development and has been moved to the EthereumJS VM monorepo.
https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/tx
Mozilla Public License 2.0
779 stars 235 forks source link

How get unsigned transaction (hex string) ? #120

Closed mason276752 closed 5 years ago

mason276752 commented 5 years ago

How get unsigned transaction (hex string) and from unsigned transaction(hex string) to signed transaction ?

let tx1=new EthereumTx({from:'0x',to:'0x',value:'0',gasLimit,.....});
let hexTx = tx1.????;

let tx2 = EthereumTx.from(hexTx) // ?????
tx2.sign(privateKey) 
tx2.serialize() 
holgerd77 commented 5 years ago

You have to provide context on what is not working for you, e.g. by providing the console output you get.

mason276752 commented 5 years ago

I want to make a cold wallet, so need to make an unsigned transaction and send it to the cold wallet. I don't have console output, just an idea , but I don't know how to do it.

danjm commented 5 years ago

@Lursun The example in this repo (https://github.com/ethereumjs/ethereumjs-tx/blob/master/examples/transactions.js) walks through how to create an ethereumjs-tx instance, edit the transaction data and then sign it with a private key.

If you wish to send that transaction over a network, you likely want to use web3. This example should be helpful in that case: https://github.com/ethereum/wiki/wiki/JavaScript-API#example-46