Skip to content

Instantly share code, notes, and snippets.

@luchenqun
Last active June 6, 2024 01:22
Show Gist options
  • Save luchenqun/52225010441e55ac0823df4a3729c2f8 to your computer and use it in GitHub Desktop.
Save luchenqun/52225010441e55ac0823df4a3729c2f8 to your computer and use it in GitHub Desktop.
Due to my poor English, I have prepared a cheat sheet. So, I hope there won't be any unexpected situations later on. If any occur, I will switch to speak Chinese.
Dear leaders and colleagues:
I am honored to share with you that the Cosmos tool I developed has been awarded the Innovation Star by our company at this special moment. I am extremely grateful and happy for this recognition.
Firstly, I would like to share the purpose behind developing this tool. As a blockchain developer in our team, my intention was to provide a simple development environment for our team members, thereby enhancing our team's development efficiency.
Next, let me introduce the main uses of this tool. With the Cosmos tool, we can view real time information about the Cosmos blockchain, such as block details, transaction information, account details, and validator information. Of course, we can also send transactions by this tool.
Lastly, I want to express my gratitude to the company for encouraging innovation. I hope that this tool marks the beginning of my innovation journey. Let's work together and strive to bring more innovative accomplishments to the company.
Now, please allow me three minutes to give a brief online demonstration of this Cosmos tool.
This is the dashboard page of the tool, where you can view the status of the blockchain. For example, you can see the current block height, confirmed transactions, average block time, and more. Additionally, the page provides real time updates on the latest blocks and transactions.
The block page allows you to view the historical records of all blocks and their details.
The transaction page is similar to the block page.
This is the account page, where you can see a list of related accounts and their details. By accessing the account details, you can view the transaction history associated with that account.
The validator page provides information about validators, including relevant details and pending reward distributions.
The proposal page displays all the proposal information on the chain.
Lastly, there is the transaction submission page, where we can easily send various types of transactions, such as transfer, delegate, undelegate, and more. Now, I will demonstrate how to send a transfer transaction. Simply fill in the necessary information, click on the "Send" button, and the transaction will be completed.
I have completed all the demonstration. Thank you all!
import { ApiPromise, WsProvider } from '@polkadot/api';
async function subscribeTemplatePallet() {
// 连接到 Polkadot 节点
const provider = new WsProvider('ws://localhost:9944');
const api = await ApiPromise.create({ provider });
// 订阅 template pallet 中的值更新
api.query.templateModule.something((result) => {
console.log('Something updated:', result.toHuman());
});
// 订阅 template pallet 中的事件
api.query.system.events((events) => {
events.forEach((record) => {
const { event } = record;
if (event.section === 'templateModule' && event.method === 'SomethingStored') {
console.log('SomethingStored event:', event.data.toString());
}
});
});
// 等待更新和事件
await new Promise((resolve) => setTimeout(resolve, 60000));
// 关闭连接
api.disconnect();
}
subscribeTemplatePallet().catch(console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment