0

I have written a contract which read and write data into blockchain using truffle. when i deployed that contract on rinkeby and called functions using web3.js the read functions works fine. but write function does not work. On reading i came to know that each transaction has to be signed by private key , but could not find proer tutorial or steps on this.

I have checked web3 provider and it seems to be ok and isConnected() returns true.

0

While instantiating web3 provider you can provide localhost:8545 if your node has personal option activated which means it has wallets in itself and it has custom provider for singing for example parity or geth.

Or if you use rpc provider like infura you have to generate wallet using web3 and save that private key for later.

To generate: http://web3js.readthedocs.io/en/1.0/web3-eth-accounts.html#create

Next time add wallet using that private key: http://web3js.readthedocs.io/en/1.0/web3-eth-accounts.html#privatekeytoaccount

And when sending TX to contract it will automatically be signed.

Note that this is documentation for web3 1.0, and these features are not supported by old web3 and you should switch or try using rpc clients like parity and geth.

Share code for better answer.

Good luck :)

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.