The Sequence SDK is available via npm. Node 4 or greater is required.
To install,
add the sequence-sdk NPM module to your package.json:
{
"dependencies": {
"sequence-sdk": "~2.2.4"
}
}If you're using TypeScript,
include the following in your tsconfig.json:
{
"compilerOptions": {
"lib": ["es2015", "es2016", "esnext"],
"types": ["node"]
}
}Also, run:
npm i --save-dev @types/node
constsequence=require('sequence-sdk')constledger=newsequence.Client({ledgerName: 'ledger',credential: '...',})Most SDK methods return Promise objects, which you can use with async/await, or consume directly.
With async/await:
asyncfunctionmain(){try{constaccount=awaitledger.accounts.create({...})// operate on account}catch(err){// handle errors}}With the Promise object itself:
functionmain(){returnledger.accounts.create({...}).then(account=>{// operate on account}).catch(err=>{// handle errors})}Comprehensive instructions and examples are available in the developer documentation.