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
Client methods
-
register(verifyKey)
: Register the current user
-
getSecpAccount()
: Get account info for the SECP subwallet
-
getAgentAccount()
: Get account info for the agent subwallet
-
sendTokens(targetAddress, amount, denom)
-
targetAddress
: A wallet address to send coins to
-
amount
: Any positive number
-
denom
: Coin type. Optional, defaults to "uixo"
.
-
getDidDoc(did)
: Return the full DID document for the given DID
-
listProjects()
: Lists all available projects
-
listTemplates()
: Lists all available templates
-
listCells()
: Lists all available cells
-
getProject(projectDid)
: Get complete project record for the given DID
-
getTemplate(tplDid)
: Get complete template record for the given DID
-
getCell(cellDid)
: Get complete cell record for the given DID
-
createProject(projectData, cellnodeURL)
: Create a new project
-
createProjectFile(target, dataUrl)
: Upload a file to project's cell node
-
getProjectFile(target, key)
-
target
: Either a project record, a project DID, or a cell
node URL
-
key
: Key of the target file, as returned from
createProjectFile
.
-
listAgents(projectRecordOrDid)
: List agents belonging to a given project
-
createAgent(projectRecordOrDid, agentRecord)
: Create an agent for the given project
-
updateAgentStatus(projectRecordOrDid, agentDid, updates)
-
listClaims(projectRecordOrDid, projectTemplateId)
projectTemplateId
: Optional, provide a value to filter claims
by template id
-
createClaim(projectRecordOrDid, claimData)
claimData
: Any object is accepted
-
evaluateClaim(projectRecordOrDid, claimId, status)
-
custom(walletType, msg)
: Send a custom message to the blockchain
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.