Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

How to query transaction use scale.rb #33

@gith-u-b

Description

@gith-u-b
  // http "localhost:8080/worker/transferHash" hash=0xe538bc7a849674eee8a80e13e7d3ef16848884378860d1e15fa7bd5f26fc09e0
  server.post<{ Body: { pay: string, hash: string } }>("/worker/transferHash", async (request, reply) => {
    let { pay, hash } = request.body

    let wsProvider = new WsProvider('wss://rpc.polkadot.io');

    if(pay == 'dot') {
      wsProvider = new WsProvider('wss://rpc.polkadot.io');
    }

    if(pay == 'ksm') {
      wsProvider = new WsProvider('wss://kusama-rpc.polkadot.io');
    }
    
    const api = await ApiPromise.create({ provider: wsProvider });

    const apiAt = await api.at(hash);

    const res = await apiAt.query.system.events();

    return { hash: res }
  });

params:

{
    "pay": "ksm",
    "hash": "0x644ca2c9d51ebac88642575ef2683298030f150b1961d68ce866ae871f2c0bea"
}

can get datas:

...
"event": {
                "index": "0x0402",
                "data": [
                    "HhZPpZPBprLxZxabTiCGuASaPPthsd856kdPhAtCBafd8Sk",
                    "DkfU3g34NVrxEt4L4NK8uqez2ARLT7W4QGC98PCkjTdsPoV",
                    100000000000
                ]
            },
            "topics": []
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions