0

I have this code which gives JSON error in web3. I tested the connections and reading the contract and that all works. There is something wrong with the "data" key in the JSON. Somehow the addBonus function is not being understood. That is an update function.

addBonus is the correct name as follows -

function addBonus( string bonusType, uint bonusTarget,  uint bonusEndYear,
    uint bonusEndMonth, uint bonusEndDay, 
    string bonusToken, uint bonusAmount, string bonusName, uint ineq ) public { ...

Has someone an example of how to write a raw txn to update a contract using web3js and nodejs?

Calling code -

    var rawTransaction = {"from":myAddress,
    "gasPrice":web3js.toHex(20* 1e9),
    "gasLimit":web3js.toHex(210000),
    "to":contractAddress,
    "value":"0x0",
   "data":contract.addBonus(bonusType, target, year, month, day, token, bonus, bonusName, ineq),
    "nonce":nounce}

The error -

node_modules/web3/lib/web3/httpprovider.js:92 throw errors.InvalidResponse(request.responseText); ^

Error: Invalid JSON RPC response: ""

1

This works:

 "data":contract.addBonus.getData(bonusType, target, year, month, day, token, bonus, bonusName, ineq),

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.