Skip to content

Instantly share code, notes, and snippets.

@jimmychu0807
Created March 4, 2020 11:58
Show Gist options
  • Save jimmychu0807/ae7ffd26489fb29d26e37201697b6de7 to your computer and use it in GitHub Desktop.
Save jimmychu0807/ae7ffd26489fb29d26e37201697b6de7 to your computer and use it in GitHub Desktop.
Markdium-用 Polkadot-JS API 輕鬆搭建 Substrate 前端
// 從 Alice 提交一個交易給另一用戶
const unsub = await api.tx.balances
.transfer(recipient, 12345)
.signAndSend(alice, ({ eventRecords = [], status }) => {
console.log(`Current status is ${status.type}`);
if (status.isInBlock) {
console.log(`Transaction included at blockHash ${status.asInBlock}`);
} else if (status.isFinalized) {
console.log(`Transaction finalized at blockHash ${status.asFinalized}`);
unsub();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment