Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
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
Supplier API is one of the Skey Network's components that allows the Supplier’s dApp to be managed. It allows for example:
the creation of new accounts for devices in the blockchain, known as wallets;
moderation of devices' metadata such as name, description, geolocation;
management of the devices' keys ( creating, transferring, blocking).
Documentation, usage examples and error codes can be found at https://demo.supplier-api.SkeyNetworkplatform.com/api_docs/ . The analysis of documentation should start with the tools, in particular /utils/setup.
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
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
The idea of Skey Network, as a communication and access control standard, is to give NFT tokens real, physical value and usability throughout world. The key to a Skey Network device should be a combination of three different technologies packaged in a form that is transparent to the user.
The first technology is BoT (Blockchain of Things). BoT is used to connect an IoT device’s unique IT record to the Blockchain. IoT devices can be installed in all kinds of physical objects such as cars, gates, homes, parking lots, offices, parcel locker systems, and so on.
The second technology is the Oracle system. Skey Network uses the second generation Oracle system. It’s goal is to connect IoT platforms with blockchain state.
The third technology, used to create the access token is the Smart Contract conditions. These conditions can be decided by the person/company/institution issuing the contract with various levels of customization. These conditions include (but are not limited to): contract expiration time, time of access, price, rules for user verification and deposit amount, and others.
The result of these technologies’ usage is a platform that connects physical devices to blockchain and creates a reliable protocol to grant permissions to access those devices.
This value can then be sold using a simple website or application, traded on exchanges, or used to build new business models.
From a business perspective, NFT access tokens are unique non-destructible keys created from a combination of the above technologies. Such keys can then be:
rented
sold
replaced
used to create new business models based on the Sharing Economy
This approach has taken NFT tokens to a completely new ideological level, giving them usability and specific functionalities.
Additionally, each NFT access key has a supplier-defined expiration date, after which it loses its functionality. The cost of generating an NFT access key depends on its lifetime, which is counted per minute. The longer the lifetime, the higher the cost of generating the key.
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
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
When this API creates a new blockchain account, its seeds are encrypted with AES using crypto-js:
https://www.npmjs.com/package/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
The mobile app serves as a wallet that stores the NFT token. The Waves libraries implemented in the app enable operations to be performed directly on the blockchain.
The procedure to add a new user to the Skey Network Ecosystem is done through the Supplier API using the POST /users endpoint. An example of this procedure can be found at this address:
The procedure consists of generating the address and recording information about it in the Supplier dApp. At the same time, a request is made for the transfer of funds for execution fees.
The procedure to add a new device to the Skey Network Ecosystem is done through the Supplier API using the POST /devices endpoint. An example of this procedure can be found at this address:
The whole procedure involves generating a blockchain address, uploading the appropriate script to it and storing information about it in the Supplier dApp. The new device address must be stored in the Supplier IoT Platform and paired with the physical device. This pairing is necessary because further identification will only take place through the blockchain address, and the IoT Platform needs to know which physical device is involved.
Additional information such as name and geographical coordinates are also stored in the Data Storage of the device wallet. Fields are defined in advance as the Standard.
Procedure for generating a new key in the Skey Network ecosystem is done through the Supplier API using the POST /keys endpoint. An example of this procedure can be found at this address:
The maximum number of keys that can be created in a single request is 80. If the recipient's address is not provided (by adding the recipient parameter in the payload POST /keys the key is automatically transferred to the specified address after being generated), the created key will remain in the Supplier's wallet. Otherwise, the key will be sent to the recipient address according to the recipient parameter.
The key, which remains in the Supplier wallet after its generation, can be transferred at any time through the endpoint PUT /keys/{assetId}/transfer/{address} in the Supplier API to any address (User).
By adding the recipient parameter in the payload POST /keys, the key is automatically transferred to the specified address.
Transferring the key is equivalent to transferring the rights to the device. Only the User/Supplier who has it in their wallet can transfer it.
The transfer can be performed from the mobile application or from the Supplier API using the endpoint PUT /keys/{assetId}/transfer/{address}, where assetId is the blockchain identifier of the key and the address parameter is the address to which the key is transferred. The address of the Supplier API procedure is as follows:
https://demo.supplier-api.SkeyNetworkplatform.com/api_docs/#/keys/KeysController_transfer