@ixo/client-sdk

One ixo client to rule them all


License
ISC
Install
npm install @ixo/client-sdk@1.2.3

Documentation

ixo-client SDK

A complete package of client software for developing client applications which connect to the ixo software stack and build on the Internet of Impact.

Usage Example

const {makeWallet, makeClient} = require('@ixo/client-sdk')

const
    wallet = await makeWallet(),
    client = makeClient(wallet)

await client.register()

await client.sendTokens('<target address>', 10)

const someProject = await client.getProject('<a valid project DID>')

const someClaims = await client.listClaims(someProject)
console.log('Here are the claims', someClaims)

See client API and wallet API for details.

Client API

Client methods:

Create a new client

  • makeClient(signer, blockchainURL, blocksyncURL): Create a new ixo client

    • signer: Either a wallet object created by makeWallet or a custom signer object with the following properties:

      • secp: Object with the following properties:

        • address
        • sign(address, document)
      • agent: Object with the following properties:

        • did
        • address
        • sign(address, document)

      See the wallet API for more info on secp and agent keywords.

      Optional. If empty, client methods that require a signer won't work.

    • blockchainURL: The URL of the target ixo chain. Optional, defaults to the current mainnet URL.

    • blocksyncURL: The URL of the target ixo blocksync service. Optional, defaults to the current main blocksync service URL.

Client methods

Wallet API

makeWallet(source, serializationPwd): Create a new wallet

  • source: Either a mnemonic string, a serialized wallet string, or a plain object representing a wallet state (possibly obtained via toJSON() -see below for details). Optional.

    If empty, a brand new wallet is generated. If a mnemonic string, recovers a wallet based on the mnemonic. If serialized wallet, deserializes it. If a state object, revives the wallet using that state.

  • serializationPwd: Serializations involve encryption so a password is required if the first parameter is an encryption string.

makeWallet returns a wallet object with the following properties:

  • secp: An instance of CosmJS' Secp256k1HdWallet

  • agent: An instance of IxoAgentWallet which is a subclass of Secp256k1HdWallet and 100% API compatible with it.

  • toJSON(): Standard toJSON method for JSON.stringify integration. One can also use this to get a representation of the wallet's internal state as a plain object and use it in a context where a class instance is not supported. (e.g. Global application state of a client app)

Debugging

Put the ixo-client-sdk string into your DEBUG environment variable to log network requests and responses. See the debug package for more info.