【问题标题】:How to get BURST acount balance using BURSTJS?如何使用 BURSTS 获取 BURST 账户余额?
【发布时间】:2019-10-28 18:08:34
【问题描述】:

以下包中的模块功能是什么来获得 BURST 帐户余额? https://burstappsteam.org/phoenix/ https://www.npmjs.com/search?q=burstjs 之后就只有几句话,还想再详细解释一下。

【问题讨论】:

  • 文档就在您发布的页面上。您尝试了哪些我们可以解决的问题?没有人会为您编写代码,但我们可以帮助您解决错误。
  • stackoverflow.com/questions/415511/… 谢谢你的建议,兄弟,我认为我的问题与这个类似.....但是如何使用全新的库 Burstjs 获得 acc 平衡.....为什么不尝试帮助我一点..拜托。

标签: javascript java reactjs typescript react-native


【解决方案1】:

在没有尝试的情况下,我仍然会使用您自己发布的链接回答您的问题。

连接区块链:

// using core
const api = b$.composeApi({
  nodeHost: "http://at-testnet.burst-alliance.org:6876",
  apiRootUrl: "/burst"
});

api.network.getBlockchainStatus().then(console.log);
// using crypto
console.log(b$crypto.hashSHA256("test"))
// using util
const value = b$util.convertNumberToNQTString(1000)
// using http
const client = new b$http.HttpImpl('https://jsonplaceholder.typicode.com/');
client.get('/todos/1').then(console.log)

然后在一个单独的文件中(“最好 index.js 或 main.js 像这样写你的入口点:”)

import {composeApi, ApiSettings} from '@burstjs/core'
import {convertNQTStringToNumber} from '@burstjs/util'

const apiSettings = new ApiSettings('http://at-testnet.burst-alliance.org:6876', 'burst');
const api = composeApi(apiSettings);

// this self-executing file makes turns this file into a starting point of your app

(async () => {
  try{
    const {balanceNQT} = await api.account.getAccountBalance('13036514135565182944')
    console.log(`Account Balance: ${convertNQTStringToNumber(balanceNQT)} BURST`)  
  }
  catch(e){ // e is of type HttpError (as part of @burstjs/http)
    console.error(`Whooops, something went wrong: ${e.message}`)      
  }
})()

如果这不能满足您的回答,请查看文档页面。

【讨论】:

    猜你喜欢
    • 2011-12-09
    • 1970-01-01
    • 2022-08-17
    • 2021-07-22
    • 2020-01-14
    • 1970-01-01
    • 2015-11-25
    • 1970-01-01
    • 2018-06-22
    相关资源
    最近更新 更多