Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
After downloading the project and entering the project folder, do the following:
Install the packages:
run yarn
if you’re using Yarn;
or
npm install
if you’re using NPM
In the main project folder create a new file called .env and fill it with environment variables.
Run the API in development mode by running npm run start:dev
To start in production mode, run npm run start:prod
The SmartKey node REST API is the main interface to interact with the blockchain. Documentation, usage examples and error codes can be found at:
https://master.testnet.node.smartkeyplatform.io/api-docs/index.html
Every Supplier has its own Blockchain wallet. The seed to this wallet should be included in the .env file.
A valid Supplier wallet needs to have the following properties:
Valid account script;
Data entries:
name: string
- name of the organisation
description?: string
- optional - short description of the organisation
type: string = “supplier”
The setup process can be performed manually or by sending a POST request to the API endpoint named /utils/setup.
This endpoint will set up the account depending on sent parameters. Sending setScript will upload the script to the blockchain wallet.
IMPORTANT: Make sure the wallet has enough SkeyUSD to perform the transactions.
Available parameters and examples are available here:
https://dev.orange.api.smartkeyplatform.io/api_docs/#/utils/UtilsController_setup
After downloading the project and entering the project folder, do the following:
In the main project folder create a new file called .env.docker
and fill it with environment variables.
Run docker build . --tag supplier-api:latest
After building has finished, run docker run supplier-api:latest
When this API creates a new blockchain account, its seeds are encrypted with AES using crypto-js:
Example usage of decryption using crypto-js:
Variable name | Example value | Description | Required |
---|
PORT | 3000 | Port to run the app | NO |
LOG_LEVEL | standard | Set log level. Available modes are ( none, standard, debug ). Logs are also saved in logs.txt file | NO |
ADMIN_EMAIL | admin@admin.com | Admin e-mail address | YES |
ADMIN_PASSWORD | password | Admin password | YES |
JWT_SECRET | jwtsecretstring | JSON Web Token(JWT) secret phrase for authorisation encryption | YES |
JWT_VALID_TIME | 1h | Time period after which JSON Web Token expires - default is 24h. Value should be compliant with this format | NO |
DB_KEY | supplierAPI | SQLite database key | NO |
DB_PATH | ./db.sqlite3 | Relative path to the SQLite database | YES |
BLOCKCHAIN_SEED | auto deposit have lake easy minute donkey solution okay account utility lady unusual actual idle | Supplier wallet backup phrase | YES |
BLOCKCHAIN_NODE_URL | URL to the Skey Network public blockchain node | YES |
BLOCKCHAIN_CHAIN_ID | T | Chain ID of Skey Network blockchain | YES |
SUPPLIER_URL | IoT Platform API URL | YES |
SUPPLIER_API_KEY | iotexamplekey | IoT Platform API key | NO |
FAUCET_DEVICE | 10000000 | Number of Skeylets to transfer to created device | NO |
FAUCET_USER | 10000000 | Number of Skeylets to transfer to created user | NO |
KEY_MIN_DURATION | 3600000 | Minimal time in milliseconds for which created Skey Network Keys can be valid - default is 1 hour | NO |
ENCRYPTION_SALT | examplesalt123 | Salt phrase used to encrypt saved account seeds when creating blockchain accounts | YES |
ENCRYPTION_IV | 0d8fa75738410842 | Initialisation Vector(IV) used to encrypt saved account seeds when creating blockchain accounts | YES |
DEVICE_SCHEMA_VERSION | 1.0 | Version of device address schema (saved on the blockchain) | NO |
CORS_ORIGIN | CORS origin link - default is “*” | NO |
Test over here: https://www.devglan.com/online-tools/aes-encryption-decryption
mode: CBC
keySize: 256
IV: set in ENV variable ENCRYPTION_IV
SecretKey: ENCRYPTION_SALT => SHA256 => first 32 letters
outputFormat: Base64