1

goes easy on me because I'm quite new to all of this stuff.

So I've created a function which signs my transaction using web3js library and looks like this:

   signTx = async () => {
     const { accounts, contract, web3} = this.state
     const msg = 'henlo frendo'
     const hex_msg = web3.utils.toHex(msg)
     let signature = await web3.eth.sign(hex_msg, accounts[0])

     signature = signature.substr(2);
     var r = '0x' + signature.slice(0, 64)
     var s = '0x' + signature.slice(64, 128)
     var v = '0x' + signature.slice(128, 130)
     var v_decimal = this.state.web3.utils.toDecimal(v)
     //v_decimal has to be either 27 or 28
     if (v_decimal != 27 || v_decimal != 28) {
       v_decimal += 27
     }

    // Get the value from the contract to prove it worked.
const fixed_msg = `\x19Ethereum Signed Message:\n${msg.length}${msg}`
const fixed_msg_sha = this.state.web3.utils.sha3(fixed_msg)
const response = await contract.methods.recoverAddr(fixed_msg_sha, 
v_decimal, r, s).call()

};

I can clearly see the that the transaction is signed properly if I do some console logs, but for example if I add a button to my front end which keeps calling this signTx() function, new transaction is never being made. What is the reason of this? Is it because I'm not fueling transaction with funds? If anyone could provide some documentation regarding this I would highly appreciate it!

P.S. I am using ganache as my network provider.

1

Well I guess the answer is because making call() on a contract only reads the data

Reffer to: https://truffleframework.com/docs/truffle/getting-started/interacting-with-your-contracts

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.