Integrate Skynet package into your Project
Introduction to Skynet
What is the Skynet Package?
This package handles CRUD (Create, Read, Updated, and Delete) operations for applications deployed to Skynet.
Here are some things you need to know about a SkyID:
It can have single or multiple applications. For example, a database, backend, and frontend website deployed as three applications under a SkyID with an ID 1535.
You need sUsd tokens to run your SkyID, and you have to deposit them into the SkyID.
The package is modular; this means you can extend and modify it according to your specific use case.
The Skynet package handles:
Contract interactions.
Application encryption and decryption.
Manages uploading and downloading of application payloads to and from decentralized storage platforms.
Perform CRUD operations on your application–Application manager.
Estimates and manages the cost of running an application; this happens through a drip manager.
Prerequisite
To get the best out of this package and the contract calls to perform for specific use cases. You need to:
Have a basic understanding of Blockchain technology.
An understanding of smart contracts.
Node.js and npm set up.
A decentralized application project.
To carry out these contract initialization and calls appropriately. You should include the required files for your specific use case in your project’s root directory.
Installation
Run this in your project's root directory:
Initialise Contract Service
It contains the required definitions for contract application deployment to initialize contract service. Implement this code:
Explaining the parameters:
provider
:Initializes a Web3 provider using thewindow.ethereum
object. The provider here allows the application to read from and send transactions to the Ethereum blockchain.signer
: This allows users to sign transactions and applications to initiate state-changing operations on the blockchain.contractInstance
: it's an SDK library that is used to create an instance of contracts that contains the main contracts deployed in the Skynet chain.address
: The Ethereum address associated with your wallet would be used for performing the transactions. Ensure the signer is authorized to act on behalf of this address.skyMainBrowser
: This initializes an instance ofskyMainBrowser
while passingcontractInstance
,address
, and a new instance ofSkyBrowserSigner
.
Mint and Fetch SkyId
To mint and fetch the ID of a SkyID, implement this code:
The code does the following:
The
fetchNFTID
function helps you mint a new NFT and fetch the ID of the NFT owned by a specific address.
Fetch Application List
Use this code to implement:
Implementing this code does the following:
It retrieves the applications that are linked to specific SkyIDs.
After retrieving, services related to the applications can be accessed or used.
Last updated