๐ Setup
Project setupโ
Create a new project in a fresh directory and navigate into it by running mkdir kilt-rocks && cd kilt-rocks
.
The dependencies needed are the following:
- KILT SDK-JS - for KILT functionality
- dotenv - to load environment variables
- If you use Typescript and not JavaScript ts-node and Typescript - to execute TS code
- Typescript
- Javascript
Initialize the project and install dependencies.
- npm
- Yarn
- pnpm
npm init -y
npm install @kiltprotocol/sdk-js dotenv ts-node typescript
yarn init -y
yarn add @kiltprotocol/sdk-js dotenv ts-node typescript
pnpm init -y
pnpm add @kiltprotocol/sdk-js dotenv ts-node typescript
Initialize the project and install dependencies.
- npm
- Yarn
- pnpm
npm init -y
npm install @kiltprotocol/sdk-js dotenv
yarn init -y
yarn add @kiltprotocol/sdk-js dotenv
pnpm init -y
pnpm add @kiltprotocol/sdk-js dotenv
Project Folderโ
- Typescript
- Javascript
Create the following remaining files and folders to end up with the folder structure below:
โโ kilt-rocks/ # project
โโ attester/ # all attester code
โโ claimer/ # all claimer code
โโ verify.ts # all verifier code
โโ .env # environment variables
mkdir attester claimer && touch verify.ts .env
Create the following remaining files and folders to end up with the folder structure below:
โโ kilt-rocks/ # project
โโ attester/ # all attester code
โโ claimer/ # all claimer code
โโ verify.js # all verifier code
โโ .env # environment variables
mkdir attester claimer && touch verify.js .env
PILT Tokensโ
This workshop interacts with the Peregrine test blockchain, which requires you to pay for each transaction with Peregrine Kilt (PILT) tokens.
But don't worry. PILT tokens have no value, and you can request them from the faucet.
Blockchain Connectionโ
Before using any SDK functionality, you must initialize and configure the Kilt SDK.
As this workshop uses the Peregrine Testnet you use its address whenever using the SDK to interact with the Kilt blockchain.
You do this by calling the following function:
await Kilt.connect({address})
Where address
is the address of the full node you want to connect to, which for this workshop, is wss://peregrine.kilt.io
.
For convenience, add the address to the .env
file.
WSS_ADDRESS=wss://peregrine.kilt.io
That's it for the basic setup - You're good to go!