# @turajs/core

Core functions and models for building Signum blockchain applications.

## Installation

SignumJS 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 @turajs/core
```

or using [yarn](https://yarnpkg.com/):

```
yarn add @turajs/core
```

#### Example

```js
import {LedgerClientFactory} from '@turajs/core'
import {Amount} from '@turajs/util'

const ledger = LedgerClientFactory.create({
    nodeHost: 'https://europe3.testnet.signum.network'
});

// this self-executing file makes turns this file into a starting point of your app

(async () => {
    try{
        const {balanceNQT} = await ledger.account.getAccountBalance('13036514135565182944')
        console.log(`Account Balance: ${Amount.fromPlanck(balanceNQT).toString()}`)
    }
        catch(e){ // e is of type HttpError (as part of @turajs/http)
        console.error(`Whooops, something went wrong: ${e.message}`)
    }
})()
```

#### Alternative Example

This example is the same as the above but using the alternative LedgerClientFactory

```js
import {LedgerClientFactory} from '@turajs/core'
import {Amount} from '@turajs/util'

const ledger = LedgerClientFactory.create({
    nodeHost: 'http://localhost:6876'
});

// this self-executing file makes turns this file into a starting point of your app

(async () => {
    try{
        const {balanceNQT} = await ledger.account.getAccountBalance('13036514135565182944')
        console.log(`Account Balance: ${Amount.fromPlanck(balanceNQT).toString()}`)
    }
    catch(e){ // e is of type HttpError (as part of @turajs/http)
        console.error(`Whooops, something went wrong: ${e.message}`)
    }
})()
```


### Using in classic `<script>`

Each package is available as bundled standalone library using IIFE.
This way _signumJS_ can be used also within `<script>`-Tags.
This might be useful for Wordpress and/or other PHP applications.

Just import the package using the HTML `<script>` tag.

`<script src='https://cdn.jsdelivr.net/npm/@turajs/core/dist/signumjs.min.js'></script>`


#### Example

```js
(function(){
    const ledger = sig$.LedgerClientFactory.create({nodeHost: "https://testnet.burstcoin.network:6876"});
    ledger.network.getBlockchainStatus().then(console.log).catch(console.error);
})()
```


See more here:

[@turajs/core Online Documentation](https://signum-network.github.io/signumjs/module/core)
