<!-- Canonical: https://docs.linea.build/network/how-to/deploy-smart-contract/cookbook -->

> For the complete Linea documentation index, see [llms.txt](/llms.txt).
> Agents can fetch this page as Markdown at [https://docs.linea.build/network/how-to/deploy-smart-contract/cookbook.md](https://docs.linea.build/network/how-to/deploy-smart-contract/cookbook.md).

# Cookbook.dev

[Cookbook.dev](https://contracts.cookbook.dev/) is an open-source smart contract registry where developers can find solidity primitives, libraries, and smart contracts for protocols. It provides an easy and fast way to develop smart contracts by integrating with a variety of blockchain-native developer tools.

Here, we'll walk through searching for a protocol on Cookbook and deploying it to Linea using Cookbook's no-code deploy and using Cookbook with Remix, Hardhat and Foundry.

## Search Cookbook's smart contract registry

Navigate to [cookbook.dev/chains/Linea](https://contracts.cookbook.dev/chains/Linea) and explore **Protocols** on Linea, or search for specific smart contracts in the search bar.

![Cookbook Search](/img/get_started/how_to/deploy_smart_contract/cookbook/Linea_deploy_smart_contract_Cookbook_1.png)

To learn about a smart contract on Cookbook, select the protocol, and select **Expand**. This opens the code alongside ChefGPT, Cookbook's AI Solidity assistant.

Highlight selections of the code and press **Analyze Snippet** to get more information about the smart contract code you're looking at, or ask ChefGPT questions about Linea, solidity, or your smart contract.

![Cookbook Analyze Code Snippet](/img/get_started/how_to/deploy_smart_contract/cookbook/Linea_deploy_smart_contract_Cookbook_2.png)

## Import smart contract code into Cookbook

Import verified smart contract code into Cookbook to fork, learn about, or build with by inputting any smart contract address that's verified on an EVM-based block explorer into the Cookbook.dev search bar.

![Cookbook Import Contract](/img/get_started/how_to/deploy_smart_contract/cookbook/Linea_deploy_smart_contract_Cookbook_3.png)

## Deploy a smart contract without coding

The **No-Code Deploy** filter enables you to view (usually simpler) smart contracts on [Cookbook](https://contracts.cookbook.dev/search?filter=No-Code+Deploy) that don't require coding to deploy.

![Cookbook No Code Deploy](/img/get_started/how_to/deploy_smart_contract/cookbook/Linea_deploy_smart_contract_Cookbook_4.png)

1.  Connect your MetaMask Wallet to Cookbook.dev.

2.  Set your smart contract arguments in the Cookbook UI (if applicable).

3.  Select **Linea** or **tLinea** (Linea Testnet) under **Pick Chain**.

4.  Select **Deploy** and pay the network fee.

Manage your deployed smart contract under **My Dashboard** in Cookbook.

## Deploy your smart contract using Remix

### Method 1 - Use the Cookbook.dev website and open in Remix

On a smart contract or protocol page in Cookbook, select the **Open in Remix** option. Your smart contract will automatically be opened in a new Remix workspace.

Select **Compile** to compile your smart contract in Remix. Most contracts opened with Cookbook will automatically compile within Remix.

Refer to the [Remix instructions](/network/how-to/deploy-smart-contract/remix) for more information on how to compile and deploy smart contracts in the Remix IDE.

### Method 2 - Use the Cookbook Remix plug-in within the Remix IDE

1.  Go to [Remix.Ethereum.org](https://remix.ethereum.org) website.

2.  Add the Cookbook Plugin to Remix by clicking the Cookbook Logo under **Featured Plugins** on the Remix Homepage.

    ![Cookbook Remix Featured Plugin](/img/get_started/how_to/deploy_smart_contract/cookbook/Linea_deploy_smart_contract_Cookbook_8.png)

    Alternatively, search Cookbook and select **Activate** in the Remix Plugin Manager.

    ![Cookbook Remix Add Plugin](/img/get_started/how_to/deploy_smart_contract/cookbook/Linea_deploy_smart_contract_Cookbook_9.png)

3.  Search for any protocol or smart contract and click the search result to import the smart contract code into Remix.

    Cookbook's AI solidity co-pilot, ChefGPT, is available within the Remix plugin to answer questions about Linea, Solidity, or the smart contract you're working with.

    ![Cookbook Remix Search](/img/get_started/how_to/deploy_smart_contract/cookbook/Linea_deploy_smart_contract_Cookbook_10.png)

4.  Compile and deploy the smart contract as described in [the Remix instructions](/network/how-to/deploy-smart-contract/remix).

## Deploy your smart contract with Hardhat

After finding the smart contract or protocol you want to work with in [Cookbook](https://contracts.cookbook.dev/), select the **Download Source** option and select **Hardhat** to download the contract boilerplate. For this example, we'll use the OpenZeppelin [Simple ERC-20 Token Smart Contract](https://contracts.cookbook.dev/contracts/simple-token).

### Compile the smart contract

In the project folder, install the required packages and dependencies:

```text
npm install
```

Then, compile the smart contract:

```text
npx hardhat compile
```

Add arguments to the `constructorArgs` array in the `deploy.js` file in the `scripts` folder and save. If you do not need any arguments, leave the array empty.

### Deploy the smart contract

-   Linea Sepolia
-   Mainnet

1.  In your `.env` file, add your Infura Linea API key and add your wallet private key.

```text
INFURA_API_KEY_LINEA_SEPOLIA = "<YOUR API KEY HERE>"
PRIVATE_KEY = "<YOUR PRIVATE KEY HERE>"
```

2.  In the `hardhat.config.js` file, add the following lines:

```js
const INFURA_API_KEY_LINEA_SEPOLIA = process.env.INFURA_API_KEY_LINEA_SEPOLIA;
```

```js
lineaSepolia: {
url: `https://linea-sepolia.infura.io/v3/${INFURA_API_KEY_LINEA_SEPOLIA}`,
accounts: [PRIVATE_KEY],
},
```

3.  In the `hardhat.config.js` file, uncomment the following line:

```js
const PRIVATE_KEY = process.env.PRIVATE_KEY;
```

4.  Deploy the smart contract to the Linea Sepolia testnet

```text
npx hardhat run --network lineaSepolia scripts/deploy.js
```

Hardhat will return the deployed smart contract address in your terminal. View and verify your smart contract on the [Linea Sepolia block explorer](https://sepolia.lineascan.build/).

1.  In your `.env` file, add your Infura Linea API key and add your wallet private key.

```text
INFURA_API_KEY_LINEA = "<YOUR API KEY HERE>"
PRIVATE_KEY = "<YOUR PRIVATE KEY HERE>"
```

2.  In the `hardhat.config.js` file, add the following lines:

```js
const INFURA_API_KEY_LINEA = process.env.INFURA_API_KEY_LINEA;
```

```js
linea: {
url: `https://linea-mainnet.infura.io/v3/${INFURA_API_KEY_LINEA}`,
accounts: [PRIVATE_KEY],
},
```

3.  In the `hardhat.config.js` file, uncomment the following line:

```js
const PRIVATE_KEY = process.env.PRIVATE_KEY;
```

4.  Deploy the smart contract to the Linea Mainnet:

```text
npx hardhat run --network linea scripts/deploy.js
```

Hardhat will return the deployed smart contract address in your terminal. View and verify your smart contract on the [Linea Mainnet block explorer](https://lineascan.build/).

## Deploy your smart contract with Foundry

After finding the smart contract or protocol you want to work with in [Cookbook](https://contracts.cookbook.dev/), select the **Download Source** option and select **Foundry** to download the contract boilerplate. For this example, we'll use [Cookbook's Simple ERC-20 Token Smart Contract](https://contracts.cookbook.dev/contracts/simple-token).

**Prerequisites**:

-   [Install Rust](https://doc.rust-lang.org/book/ch01-01-installation.html).
-   [Install Foundry](https://book.getfoundry.sh/getting-started/installation#using-foundryup).

1.  In the project directory, build the contracts:

```sh
forge build
```

    If you encounter a "stack too deep" error, try running the following command instead

```sh
forge build --via
```

2.  In the `scripts` directory, uncomment all the code in the `contract.s.sol` file. Replace `"ARG1"`, `"ARG2"`, `2000` with your `Token Name`, `Token Symbol` and desired `Token Quantity` where you see the code below:

```solidity
FixedToken _contract = new FixedToken("ARG1", "ARG2", 2000);
```

3.  Update the `.env` file with your [Linea RPC URL](https://docs.metamask.io/services/reference/linea/quickstart/), followed by your [MetaMask wallet private key](https://metamask.io/) and your [Etherscan API key token values](https://etherscan.io/apis).

    note

    The example uses Sepolia, but you can update it to use Mainnet instead.

4.  Run the command to define your environment variables globally:

```sh
source .env
```

5.  Deploy your contracts:

```sh
forge script script/contract.s.sol:ContractScript --rpc-url $SEPOLIA_RPC_URL --broadcast --verify -vvvv
```

    note

    If using Mainnet, then update the `--rpc-url` accordingly with the variable in the `.env` file.

Your contract will be verified on the Linea Sepolia explorer automatically upon deployment. You can manage and interact with your newly deployed smart contract in the [Linea Sepolia block explorer](https://sepolia.lineascan.build/).

note

The tests in the `contract.t.sol` file are only examples, please generate your own.

## Resources

For more information on using Cookbook to find, learn about or build with smart contracts, see the following resources:

-   [Blog](https://medium.com/@cookbookdev)
-   [X (Twitter)](https://x.com/cookbook_dev)
-   [Community](https://discord.gg/cookbook)
