Skip to main content

Foundry

In this tutorial, we'll walk through creating a basic Foundry project.

Here's a video walkthrough:

Prerequisites​

Before you begin, Ensure you've:

  1. Set up your wallet

  2. Funded your wallet with goerli ETH

  3. Bridged Goerli ETH to Linea

  4. Downloaded Foundry using the following command:

    curl -L https://foundry.paradigm.xyz | bash

    Then, open a new terminal, and call foundryup to install the latest release.

Create a Foundry project​

To create an empty Foundry project, run:

forge init linea-tutorial

And change into the directory:

cd linea-tutorial

Write the smart contract​

Running forge init sets you up with a sample contract, test, and script for Counter.sol. To build it, simply run forge build.

Deploy the smart contract​

To deploy a smart contract, run:

forge create --rpc-url https://rpc.goerli.linea.build/ src/Counter.sol:Counter --private-key YOUR_PRIVATE_KEY

Your output should look a little something like this:

Deployer: YOUR_ACCOUNT_NUMBER
Deployed to: 0xED0Ff7E8B655dFFfCA471ea3B6B649ce7C2C1b83
Transaction hash: 0x967e1290b285e67b3d74940ee19925416734c345f58bd1ec64dcea134647d7ee