Faucet
This page guides you through the process of creating a new project using the Faucet template. This template is a specialized tool for creating new tokens in the network. By utilizing the faucet template, developers can build and deploy a faucet program, and then add fungible tokens to it. Once set up, users can interact with the faucet to receive the available fungible tokens. Follow the step-by-step guide below to create and deploy your non-fungible project:
Step 1: Set Up Your Project
Create your project, with its own directory and add the necessary dependencies to it. Run the following to perform this process:
mkdir faucet-project \
&& cd faucet-project \
&& npm init -y \
&& npm install typescript --save-dev \
&& npx tsc --init \
&& npm install --save @versatus/versatus-javascript
Step 2: Start the Project
Now, initialize a new LASR project. In this guide, you will use the faucet
template:
npx lasrctl init faucet
Step 3: Set up your Wallet Keys
Replace the address
and secret_key
from the keypairs.json
file with your account keys.
If you require assistance finding your keys, refer to the Creating your First Program guide to learn where to find them.
Step 4: Build Your Program
You need to compile your TypeScript code into JavaScript before deployment. To do this, use the following command:
npx lasrctl build example-program.ts
Step 5: Test Your Program
You can now validate your program's performance against sample JSON inputs that it might encounter in real-world scenarios, as defined by the LASR protocol. To initiate the testing process, use the following command:
npx lasrctl test -b example-program -i example-program-inputs
With these tests successfully completed, your program is now prepared for deployment on the LASR network.
Step 6: Deploy Your Program
You can now start the deploy process using the npx lasrctl deploy
command. Below is the command you need to run to deploy your faucet
application:
npx lasrctl deploy --build example-program --symbol FAUCET --programName "Faucet for anything fungible" --txInputs '{"imgUrl":"https://pbs.twimg.com/profile_images/1421740863139446787/huoxhEV3_400x400.jpg"}'
For detailed information about each standard parameter, refer to the Deploy Configuration page.
Interacting With Your Program
Once the deploy is finished, you can use your faucet instance by connecting fungible programs to it, and transfering fungible tokens to any account. Follow the steps below to faucet tokens to a different account:
At the moment, only the faucet program's owner can faucet tokens from it.
-
Deploy a fungible program, adding a
recipientAddress
flag to send the initialized supply to your account's address. As the program is deployed, it will yield a program address related you will need to connect the faucet to the fungible program. -
Add the created fungible program to the faucet. For this you will use the
call
parameter oflasrctl
, adding a operation flag (--op
) to add a program:
npx lasrctl call --programAddress FAUCET_PROGRAM_ADDRESS --op addProgram \
--txInputs '{"programAddress":"FUNGIBLE_PROGRAM_ADDRESS","amountToAdd":"AMOUNT_TO_ADD","faucetAmount":"FAUCET_AMOUNT","addressTimeoutMinutes":"TIMEOUT"}'
Replacing the following information:
FAUCET_PROGRAM_ADDRESS
: The address of the faucet program you deployed.FUNGIBLE_PROGRAM_ADDRESS
: The address of the fungible program saved on Step 1.AMOUNT_TO_ADD
: The amount of the token to be added to the faucet.FAUCET_AMOUNT
: The amount that will be transferred into the new address when calling the faucet operation.TIMEOUT
: A timeout, in minutes, to block another transfer to the same address.
- With the fungible program connected to the faucet, you can send tokens to another address. For this you will use the
call
parameter oflasrctl
, adding a operation flag (--op
) to faucet tokens:
npx lasrctl call --programAddress FAUCET_PROGRAM_ADDRESS --op faucet \
--txInputs '{"programToSend":"FUNGIBLE_PROGRAM_ADDRESS","to":"SOME_OTHER_ADDRESS"}'
Replacing the following information:
FAUCET_PROGRAM_ADDRESS
: The address of the faucet program you deployed.FUNGIBLE_PROGRAM_ADDRESS
: The address of the fungible program you want to use.SOME_OTHER_ADDRESS
: An account address you want tokens to be sent to.
The faucet operation can be seen in action in Versatus Discord server. By requesting credits through the /faucet <address>
command in the faucet channel discord leverages a faucet program to send VERSE Credits to the added address.