# 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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
