> For the complete documentation index, see [llms.txt](https://docs.flexnet.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flexnet.tech/deploy-your-app/foundry.md).

# Foundry

[Foundry](https://github.com/foundry-rs/foundry) is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.

Foundry consists of:

[Forge](https://github.com/foundry-rs/foundry/blob/master/crates/forge): Ethereum testing framework (like Truffle, Hardhat and DappTools).

[Cast](https://github.com/foundry-rs/foundry/blob/master/crates/cast): Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.

[Anvil](https://github.com/foundry-rs/foundry/blob/master/crates/anvil): Local Ethereum node, akin to Ganache, Hardhat Network.

[Chisel](https://github.com/foundry-rs/foundry/blob/master/crates/chisel): Fast, utilitarian, and verbose solidity REPL.​

### Get Started with Foundry <a href="#get-started-with-foundry" id="get-started-with-foundry"></a>

1. Install Foundry

* Linux or MaxOS

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

* Windows

```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs/ | sh
cargo install --git https://github.com/foundry-rs/foundry foundry-cli anvil --bins --locked
```

2. Create a project

```bash
forge init foundry
```

3. Navigate to the Source in the project and create your smart contract

```bash
cd src
touch MyToken.sol
```

4. Input your smart contract or use the sample contract below.

```bash
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
 
contract HelloWorld {
    string public greet = "Hello World!";
}
```

5. Install OpenZeppelin contracts as a dependency

```bash
forge install OpenZeppelin/openzeppelin-contracts
```

6. Compile contract

```bash
forge build
```

### Deploying Your Smart Contract <a href="#deploying-your-smart-contract" id="deploying-your-smart-contract"></a>

Deploying a contract with Forge is a simple process that can be done with a single command. However, it requires an RPC endpoint, a private key that has funds, and any arguments for the constructor of the contract.

For example, the `MyToken.sol` contract requires an initial supply of tokens to be specified in its constructor, so the command to deploy it on a network will include the argument of 100.

To deploy the `MyToken.sol` contract, use the command that corresponds to the Mint chain’s RPC URL while running the `forge create` command:

#### Testnet <a href="#testnet" id="testnet"></a>

```bash
forge create --rpc-url "
https://rpc-testnet.flexnet.tech"
--constructor-args 100 \
--private-key YOUR_PRIVATE_KEY \
src/MyToken.sol:MyToken
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flexnet.tech/deploy-your-app/foundry.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
