Skip to content

Instantly share code, notes, and snippets.

@jimmychu0807
Created March 4, 2020 11:58
Show Gist options
  • Save jimmychu0807/4eb4f344e70970267ece72dd485bcce2 to your computer and use it in GitHub Desktop.
Save jimmychu0807/4eb4f344e70970267ece72dd485bcce2 to your computer and use it in GitHub Desktop.
Markdium-用 Polkadot-JS API 輕鬆搭建 Substrate 前端
// 初始化 `api` 對象
const api = ...;
// 取得鏈上的時間戳
const now = await api.query.timestamp.now();
// 一個模擬地址
const ADDR = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE';
// 取得用戶地址中的餘額
const balance = await api.query.balances.freeBalance(ADDR);
const nonce = await api.query.system.accountNonce(ADDR);
console.log(`${now}: balance of ${balance} and a nonce of ${nonce}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment