0


I want to send to smart contract using this code :

  this.myContract.methods.addData(declaration).send({
            from: '0x3b0282D31174B927e102bA71d80dF34F4e596Fc4',
            gas: 12000
        })

this code throws this error:

TypeError: Cannot create property 'from' on string '0xf905678001822ee09439126b2a8801909a7b379e503c5ee270ff700e0580b905043a03cbec0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000240000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000340000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000440000000000000000000000000000000000000000000000000000000000000001044442d313534393535353536333931380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000074d61726f75656e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000644626f75626100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006504153503031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073033313435363400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000653454a3031320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000354554e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e4d454c4c49544120444a4552424100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034652410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a30332d30372d3230313700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c627572656175456e747265650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c9000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000034555520000000000000000000000000000000000000000000000000000000000820bfaa01e122a6c8e460b6fef7f2beec74939f989d59d02a93e0bf6c7732a65e3bfc83ca0697dd2faf0acd7eca59cfbde11376855d1f0ed2588669f01836a7d0d9963d930'

What is exactly this error means?

  • Your gas is too little, absolute minimum is 21k and you will need more when calling a smart contract. – Ismael Feb 8 at 1:31
  • I tried with gas: 300000 and I got the same error – maroodb Feb 8 at 7:59
  • Can you share the code of the function addData? What is the value of declaration variable? – Ismael Feb 8 at 17:48
  • please see details here github.com/ethereum/web3.js/issues/2341#issuecomment-461534427 – maroodb Feb 11 at 8:08
  • What does your contract looks like? It seems you are trying to send a json object to a solidity method, try sending that a string instead. – Ismael Feb 11 at 18:27
0

Try doing it in this way -

web3.eth.contract(contract_abi).new.getData( parameter1, parameter2 // dont add parameters if you function dont have any { data: data_company.abiData, }); let gas = web3.toHex(300000) let nonce = web3.toHex(web3.eth.getTransactionCount("0x3b0282D31174B927e102bA71d80dF34F4e596Fc4")) let transactionObject = { gas: gas, data: deploy, from: "0x3b0282D31174B927e102bA71d80dF34F4e596Fc4", nonce: nonce };

  • Why I have doing it this way ? what is wrong with my solution ? – maroodb Feb 8 at 9:45

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.