For the complete documentation index, see llms.txt. This page is also available as Markdown.

Deploying

In this chapter, you'll deploy your ClownBeatdown contract to a local Seismic node for testing. By the end of this guide, you'll have a fully deployed contract that you can interact with using your CLI or scripts. Estimated Time: ~15 minutes.

Writing the deploy script

Navigate to the script folder in your project and open the ClownBeatdown.s.sol file located at:

packages/contracts/script

and add the following to it:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script, console} from "forge-std/Script.sol";
import {ClownBeatdown} from "../src/ClownBeatdown.sol";

contract ClownBeatdownScript is Script {
    ClownBeatdown public clownBeatdown;

    function run() public {
        uint256 deployerPrivateKey = vm.envUint("PRIVKEY");

        vm.startBroadcast(deployerPrivateKey);
        clownBeatdown = new ClownBeatdown(3);
        vm.stopBroadcast();

        console.log("Deployed at:", address(clownBeatdown));
    }
}

This script will deploy a new instance of the ClownBeatdown contract with an initial stamina of 3. We'll add secrets separately in the next step, since addSecret performs shielded writes that need to be sent as on-chain transactions.

Deploying the contract

  1. In a separate terminal window, run

in order to spin up a local Seismic node.

  1. In packages/contracts, create a .env file and add the following to it:

The RPC_URL denotes the port on which sanvil is running and the PRIVKEY is one of the standard sanvil testing private keys.

  1. Now, from packages/contracts, deploy the contract:

The output will show the deployed contract address (e.g. 0x5FbDB2315678afecb367f032d93F642f64180aa3).

  1. Add secrets to the deployed contract using scast send. Replace <CONTRACT_ADDRESS> with the address from the previous step:

Your contract should be up and deployed to your local Seismic node with 5 secrets!

Last updated