Skip to content

Instantly share code, notes, and snippets.

@jimmychu0807
Created March 4, 2020 11:58
Show Gist options
  • Save jimmychu0807/4fe3f8643c3474d42239e2ac823cd0c7 to your computer and use it in GitHub Desktop.
Save jimmychu0807/4fe3f8643c3474d42239e2ac823cd0c7 to your computer and use it in GitHub Desktop.
Markdium-用 Polkadot-JS API 輕鬆搭建 Substrate 前端
// 創建 api
// const api = await ...;
api.query.system.events(events => {
events.forEach(record => {
// 遍歷所有事件記錄
const { event, phase } = record;
const types = event.typeDef;
// 過濾掉我們不關注的事件
const eventName = `${event.section}:${
event.method
}:: (phase=${phase.toString()})`;
if (filter.includes(eventName)) return;
// 從這裡開始,對我們關注的事件作進一步的處理
// ...
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment