1

So I'm only using Infura and web3 here, no local node running and I want to use functions like :

mycontract.methods.function(msg).send({from: address, gas: 200000})

it won't work because it is a state changing transaction, so I need to sign.

so I have:

var signed_data = web3.eth.accounts.sign(web3.utils.fromAscii("A20160528"), private_key);

and it return to me:

{ message: '0x413230313630353238', messageHash: '0x0a30d111fed6dbde69984b1763cde3f45838c870df0132da723731d3ea1c7225', v: '0x1b', r: '0xd36db528de6bc8ba97c8dffa27fe94288af53f26b82eb5acc6983a849db99902',

s: '0x69b3e6e8ddc69eeda0774bab2801b724f7dfa9cbfed60b4fa70637d420b91b05', signature: '0xd36db528de6bc8ba97c8dffa27fe94288af53f26b82eb5acc6983a849db9990269b3e6e8ddc69eeda0774bab2 801b724f7dfa9cbfed60b4fa70637d420b91b051b' }

How should I pass this to the web3 function such as :

mycontract.methods.function(msg).send({from: address, gas: 200000})

what should I put into msg variable?

4
  • what version of Web3? 1.0.0 or the 0.x?
    – Julien
    Commented Mar 30, 2018 at 20:37
  • the version is 1.0.0
    – Alan waski
    Commented Mar 30, 2018 at 20:46
  • But I'm not using truffle here
    – Alan waski
    Commented Mar 30, 2018 at 20:56
  • have a look at sendSignedTransaction
    – Julien
    Commented Mar 30, 2018 at 21:14

0

Browse other questions tagged or ask your own question.