Node SDK

Installation

npm i sila-sdk

Adding Sila to your Node app

The current version is designed as a singleton, so you will need to use require:

sila = require('sila-sdk/lib/index.js');
sila.configure({
appKey: APPLICATION_PRIVATE_KEY,
appHandle: APPLICATION_HANDLE,
})

You can manage your apps in the Developer Console. The APPLICATION_PRIVATE_KEY is the Private Key that matches the Public Key associated with the Application Handle in your Console.

Keep your Application Private Key secure! Never share it with anyone, including us. If you believe that your private key has been compromised, please replace the key for that app with a new one in the Developer Console.

Making your first API calls

The following represents a simple registration process:

// Check Handle Availability
if(sila.checkHandle('user1234')) {
// Register a new user
sila.register({
handle: 'user1234',
first_name: 'First',
last_name: 'Last',
ssn: '123-45-6789',
phone: '(123) 456-7890',
address: '123 Main St'
city: 'Anytown',
state: 'OR',
zip: '12345-1234',
eth_address: '0x123...890',
}).then((res) => {
// Request KYC and enable the Plaid SDK button
}).catch((err) => {
// Add error handling ...
}
} else {
// Handle is already in use ...
}

Linking the account can take up to a minute to complete after the call is executed, so you'll need to check for a linked account before issuing sila:

let accounts;
sila.getAccounts('user1234', 'fc12...4e6')
.then((res) => {
accounts = res.data.accounts;
if (accounts.length) {
const amount = 20000;
sila.issue('user1234', 'fc12...4e6', amount)
.then((res) => {
const usd = amount/100;
alert(`$${usd} has been converted to ${amount} sila on your account. This transaction may take up to 3 days to complete.`);
}).catch((err) => {
// Add error handling ...
});
} else {
alert('You will need to link your bank account before you can convert USD to sila');
}
}).catch((err) => {
// Add error handling ...
});

Building your app

Check out the Full Documentation to see all of the functionality available in this release of the SDK.