Skip to main content
6 events
when toggle format what by license comment
May 18, 2022 at 13:26 comment added Andy ( String two = ten.toString(2); ) The result is binary
May 18, 2022 at 10:06 comment added Squirrel replace needs to be turned into bin from the hex string encoding that it is whereas you're trying to read it as a big integer. After the 0x there's 28 - that's 2x16 + 8 which is the byte 40 (a u8 in rust speak). You need to call Convert.FromHexString(replace) to get the scale binary and then you can decode that.
May 18, 2022 at 9:26 comment added Andy The result is still wrong. The correct result should be 1651825968. What went wrong?
May 18, 2022 at 9:25 comment added Andy public static void main(String[] args) { //TODO // Correct result: 1651825968 UInt32Reader reader = new UInt32Reader(); String str = "0x280402000b919bbc3b8001"; String replace = str.replace("0x", ""); BigInteger ten = new BigInteger(replace, 16); String two = ten.toString(2); ScaleCodecReader codec = new ScaleCodecReader(two.getBytes()); codec.hasNext(); Long read = codec.read(reader); System.out.println("timestamp:"+read); }
May 18, 2022 at 8:40 comment added Squirrel But that's all hard mode stuff. Desub might help you as strong typing probably isn't your friend here. Maybe the easier route might be to call sidecar rest urls for the data you need - that gives json back: paritytech.github.io/substrate-api-sidecar/dist
May 18, 2022 at 8:30 history answered Squirrel CC BY-SA 4.0