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

How to query transaction use scale.rb #33

Open
gith-u-b opened this issue Sep 14, 2022 · 3 comments
Open

How to query transaction use scale.rb #33

gith-u-b opened this issue Sep 14, 2022 · 3 comments

Comments

@gith-u-b
Copy link

gith-u-b commented Sep 14, 2022

  // 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": []
...
@gith-u-b
Copy link
Author

I want to use scale.rb,how can I implement this function, thanks.

@gith-u-b
Copy link
Author

@freehere107 🙏

@wuminzhe
Copy link
Collaborator

@sai1024 I will look into your issue.
It is not recommended to use it in the product. Use https://github.com/polkadot-js instead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants