1.4.17 • Published 4 years ago

@oxspacenpm/api v1.4.17

Weekly downloads
-
License
AGPL-3.0-only
Repository
github
Last release
4 years ago

OxSpaceAPI

Programming interface for communicating with blockchain and OxSpace protocol.

It uses ethers.js.

Usage

Add the package: yarn add @oxspacenpm/api

Build the IOC container and pass any necessary config options:

import {
    buildContainer,
    APIContainer,
    options,
    Network
} from 'oxspace'

let container: APIContainer = buildContainer(options.Network(Network.Local))

Then you can get any service or provider:

import {
    symbols,
    protocol
} from 'oxspace'

import { utils } from 'ethers'

let bep20 = container.get<protocol.BEP20>(symbols.protocol.BEP20)
console.log(utils.formatEther(await bep20.totalSupply()))

If you have a provider or signer, make sure to register it with Web3Provider service before making any calls to other services:

import {
    symbols,
    Web3Provider
} from 'oxspace'

import { VoidSigner } from 'ethers'

let provider = container.get<Web3Provider>(symbols.utility.Web3Provider)

// For setting a provider
provider.setWeb3Provider(window.ethereum)

// For setting default signer if no provider is set
provider.setDefaultSigner(new VoidSigner())
1.4.17

4 years ago

1.4.16

4 years ago

1.4.15

4 years ago

1.4.14

4 years ago

1.4.13

4 years ago

1.4.12

4 years ago

1.4.11

4 years ago

1.4.10

4 years ago

1.4.9

4 years ago

1.4.8

4 years ago

1.4.7

4 years ago

1.4.6

4 years ago

1.4.5

4 years ago

1.4.4

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago