0

This is the Solidity code from this oracle contract:

function transmit(bytes calldata _report, ...) external {
    ...
    (r.rawReportContext, rawObservers, r.observations) = abi.decode(
        _report, (bytes32, bytes32, int192[])
    );
}

How do I do this in Node? The code below doesn't give me the desired result. I need the 3rd part to be an array of Int but it gives me an empty array.

var abi = require('ethereumjs-abi')
let toDecode = '0x0000000000000000000000078729884873c70b69b117060ea06c5c00002e5e08040002030105060708090a0b0c0d0e0f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000009877075c0000000000000000000000000000000000000000000000000000000098783d967000000000000000000000000000000000000000000000000000000098783d967000000000000000000000000000000000000000000000000000000098783d967000000000000000000000000000000000000000000000000000000098783d967000000000000000000000000000000000000000000000000000000098783d967000000000000000000000000000000000000000000000000000000098783d967000000000000000000000000000000000000000000000000000000098783d967000000000000000000000000000000000000000000000000000000098783d967000000000000000000000000000000000000000000000000000000098783d967000000000000000000000000000000000000000000000000000000098783d967000000000000000000000000000000000000000000000000000000098783d967000000000000000000000000000000000000000000000000000000098783d967000000000000000000000000000000000000000000000000000000098783d967000000000000000000000000000000000000000000000000000000098783d9670000000000000000000000000000000000000000000000000000000988cf6980'
var res = abi.rawDecode(['bytes32', 'bytes32', 'int192[]'], toDecode)
console.log(res)

This prints:

[
  <Buffer 30 78 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 37 38 37 32 39 38 38>,
  <Buffer 34 38 37 33 63 37 30 62 36 39 62 31 31 37 30 36 30 65 61 30 36 63 35 63 30 30 30 30 32 65 35 65>,
  []
]
1
  • Are you sure that the you send the correct one? I don't want to check it. Try use abi encode and then send instead of manually create one
    – haxerl
    Sep 19 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.