> ## Documentation Index
> Fetch the complete documentation index at: https://docs.celo.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy on Celo with Foundry

How to deploy a smart contract to Celo testnet, Mainnet, or a local network using [Foundry](https://book.getfoundry.sh/).

***

## Introduction to Foundry

Foundry is a smart contract development toolchain.

Foundry manages your dependencies, compiles your project, runs tests, deploys, and lets you interact with the chain from the command-line and via Solidity scripts.

## Prerequisites

You will need the Rust compiler and Cargo, the Rust package manager. The easiest way to install both is with [rustup.rs](https://rustup.rs).

## Using Foundryup

Foundryup is the Foundry toolchain installer. You can find more about it here.

Open your terminal and run the following command:

```bash theme={null}
curl -L https://foundry.paradigm.xyz | bash
```

This will install Foundryup, then simply follow the instructions on-screen, which will make the foundryup command available in your CLI.

Running `foundryup` by itself will install the latest (nightly) precompiled binaries: `forge`, `cast`, `anvil`, and `chisel`.

## Create a new project using Forge

To start a new project with Foundry, use:

```bash theme={null}
forge init hello_foundry
```

<Note>
  If you initializing project in an already initialized git repo use:

  ```bash theme={null}
  forge init project_name --no-git
  ```
</Note>

## Adding a dependency

To add a dependency, use:

```bash theme={null}
forge install openzeppelin/openzeppelin-contracts
```

### Remapping dependencies

Forge can remap dependencies to make them easier to import. Forge will automatically try to deduce some remappings for you

```bash theme={null}
$ forge remappings

ds-test/=lib/solmate/lib/ds-test/src/
forge-std/=lib/forge-std/src/
solmate/=lib/solmate/src/
weird-erc20/=lib/weird-erc20/src/
```

These remappings mean:

* To import from `forge-std` we would write: import `forge-std/Contract.sol`;
* To import from `ds-test` we would write: import `ds-test/Contract.sol`;
* To import from `solmate` we would write: import `solmate/Contract.sol`;
* To import from `weird-erc20` we would write: import `weird-erc20/Contract.sol`;

You can customize these remappings by creating a `remappings.txt` file in the root of your project.

### Removing dependencies

You can remove dependencies using

```bash theme={null}
forge remove openzeppelin/openzeppelin-contracts
```

## Adding Celo specific config to `foundry.toml`

Add the following configuration to `foundry.toml` file in the root level of your project.

```toml theme={null}
[rpc_endpoints]
celo-sepolia = "https://forno.celo-sepolia.celo-testnet.org/"
celo = "https://forno.celo.org"
```

## Deploying contract

Forge can deploy smart contracts to a given network using:

The below example deploys `Counter` contract at location `src/Counter.sol` in the project to the Celo Sepolia Testnet.

```bash theme={null}
forge create --rpc-url celo-sepolia --private-key <your_private_key> src/Counter.sol:Counter
```

<Note>
  Notice the contract name after `:`, this is because a single solidity file can have multiple contracts.

  It is recommended to use `--verify` flag so that the contract gets verified right after deployment, this requires [etherscan configuration](/developer/verify/foundry) in the `foundry.toml` file.
</Note>

On successful deployment, you should a following output!

<Frame>
  <img src="https://mintcdn.com/celo-64ac69bd/oYb-8nnpFO3sIJto/img/doc-images/deploy-foundry/image1.png?fit=max&auto=format&n=oYb-8nnpFO3sIJto&q=85&s=a54bdd142d781b25b2d32f1910f0d5a4" alt="github" width="1718" height="128" data-path="img/doc-images/deploy-foundry/image1.png" />
</Frame>
