15

Is it possible to use the web3.js library in a client's browser to let them generate an address and sign a transaction without them connecting to an ethereum node?

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 transactions?

3
  • 1
    Looks like the data field is sent as Hex. How do I convert my function call and parameter to put it in? For example, if I want call: setName("roger") on the contract. – Max Jun 22 '16 at 16:17
  • I'm not seeing the connection between the questions. Please elaborate/clarify and ask a separate question. – eth Jun 23 '16 at 9:57
  • It is possible to sign transaction with web3js though. – Florian Castelain Jan 15 '18 at 3:28
2

It is possible to sign transaction with web3js, check the 1.0.0 version

0

I would also check out https://github.com/ethjs/ethjs-provider-signer

It has just what you are looking for.

0

I was looking for an answer to the above, figured out the following. The eth module can be used by first instantiating web3 with the default constructor and then calling the sign function.

var web3 = require('web3');
var myWeb3 = new web3();
var signedTx = myWeb3.eth.signTransaction(tx, privateKey [, callback]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.