Wie kodiere ich ein Raw Txn mit web3js?

Ich habe diesen Code, der einen JSON-Fehler in web3 ausgibt. Ich habe die Verbindungen getestet und den Vertrag gelesen und das alles funktioniert. Mit dem Schlüssel „data“ im JSON stimmt etwas nicht. Irgendwie wird die addBonus Funktion nicht verstanden. Das ist eine Update-Funktion.

addBonus ist der richtige Name wie folgt -

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

Hat jemand ein Beispiel dafür, wie man ein Roh-TXN schreibt, um einen Vertrag mit web3js und nodejs zu aktualisieren?

Anrufcode -

    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}

Der Fehler -

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

Fehler: Ungültige JSON-RPC-Antwort: ""

Antworten (1)

Das funktioniert:

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