Building and Deploying Contracts
Before following this guide, make sure you have completed the getting started guide.
Prerequisites
Before you start, you'll need to install the avs-toolkit-cli
as laid out in the getting started guide.
Set up Your Wallet
You should already have the avs-toolkit repo on your machine from installing the CLI.
In the root of the repo, run the following commands to create a wallet and a local mnemonic. This will print the mnemonic
to standard out for you to see, as well as add it to your .env
locally.
M=$(avs-toolkit-cli wallet create | tail -1 | cut -c16-)echo "TEST_MNEMONIC=\"$M\"" > .envcat .env
This should have a nice 24 word phrase.
You can use the following command to view your wallet:
avs-toolkit-cli wallet show
Giving the Wallet Some Funds
Right now, you probably don't have any funds in your wallet. You can get some from the faucet by following the steps below.
You'll need to install Telegram in order to get faucet funds for the hacknet. Visit https://telegram.org/ and follow installation instructions for your device.
- After installing Telegram, Visit https://t.me/LayerUp_bot to open the LayerUp Telegram app.
- Click Start and then Start adventure.
- After following the prompts in the app, you'll be able to open the menu in the left corner of the screen. Click the illuminated drop-shaped button.
- Scroll down and input your wallet address. You can use the following command in the CLI to view your address:
avs-toolkit-cli wallet show
- Click Claim Tokens after entering your wallet address. The faucet tokens will be sent to your wallet.
If you run the following in the CLI, you should see some funds in your wallet.
avs-toolkit-cli wallet show
Build Your Contracts
You should already have the avs-toolkit repo on your machine from completing the getting started guide.
Before proceeding, make sure that that you have already completed the getting started guide and that Docker is installed and running:
- Install Docker desktop.
- Run Docker in your desktop.
In the root of the repo, run the following to build your contracts:
./scripts/optimizer.sh
After running this, you should see several .wasm
files that correspond to your contracts in your artifacts
folder
Note: you'll need to rebuild and redeploy your contracts whenever you make any changes to them.
Deploy Your Contract
Then you can deploy with:
avs-toolkit-cli deploy --mode verifier-simple contracts --artifacts-path ./artifacts --operators wasmatic
To view the deployed contracts, you can also run
avs-toolkit-cli task-queue view-queue
It's important to be able to find the Task Contract Address and the Verifier Contract Address by using these commands, so that you can use them when developing WASM components.
Adding Tasks
To create tasks for your contract task queue, you can run the following commands.
View the queue:
avs-toolkit-cli task-queue view-queue
Add a task (in this example, we're adding a task for the squaring service example, which is covered in the getting started guide):
avs-toolkit-cli task-queue add-task -b '{"x": 12}' -d 'test 1'
Then, wait a few seconds or until the log output shows it is executed:
avs-toolkit-cli task-queue view-queue
You'll notice after adding your task, that viewing the queue will print information about the task you've added, whereas there won't be any tasks in the queue before you add them.
Connect a frontend to your contracts
Follow the frontend connection guide to learn how to connect the frontend to your contract. You'll need to edit the frontend code to add your task queue address.