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:
Funded your wallet with Linea ETH
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, we highly recommend using an Infura endpoint, as the public endpoint may experience rate limiting. You can find out how to get an API key here. Then, you can run the following command.
Using Infura:
forge create --rpc-url https://linea-goerli.infura.io/v3/YOUR-INFURA-API-KEY src/Counter.sol:Counter --private-key YOUR_PRIVATE_KEY
Using the public endpoint:
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
Next, you can optionally verify your contract on the network.
Deploy to Mainnetβ
Instructions coming soon!