有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (1) 个答案

  1. # 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}`)      
      }
    })()
    

    如果您的回答不满意,请查看文档页面