UNPKG

@fruitsjs/core

Version:

Principal package with functions and models for building Fruits Eco-Blockchain applications.

54 lines (37 loc) 1.29 kB
# @fruitsjs/core Core module to build cool apps for the Fruits blockchain platform ## Installation FruitsJS can be used with NodeJS or Web. Two formats are available ### Using with NodeJS and/or modern web frameworks Install using [npm](https://www.npmjs.org/): ``` npm install @fruitsjs/core ``` or using [yarn](https://yarnpkg.com/): ``` yarn add @fruitsjs/core ``` #### Example ```js import {composeApi, ApiSettings} from '@fruitsjs/core' import {Amount} from '@fruitsjs/util' const apiSettings = new ApiSettings('https://testnet.fwallet.net'); 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: ${Amount.fromPlanck(balanceNQT).toString()}`) } catch(e){ // e is of type HttpError (as part of @fruitsjs/http) console.error(`Whooops, something went wrong: ${e.message}`) } })() ``` #### Example ```js (function(){ const api = sig$.composeApi({nodeHost: "https://testnet.fwallet.net"}); api.network.getBlockchainStatus().then(console.log).catch(console.error); })() ```