Layer LogoLayer AVS Docs
Guides

Building and Deploying Contracts

Prerequisites

Before you start, you'll need to install the avs-toolkit-cli as laid out in Installing the CLI.

Set up Your Wallet

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 you .env locally.

M=$(avs-toolkit-cli wallet create | tail -1 | cut -c16-)
echo "TEST_MNEMONIC=\"$M\"" > .env
cat .env

This should have a nice 24 word phrase.

Once you have a wallet, you can add funds from the faucet:

avs-toolkit-cli faucet tap

You can view your funds with the following commands:

avs-toolkit-cli wallet show

Build Your Contracts

You should already have the avs-toolkit repo on your machine from installing. 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 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 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):

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.

On this page