# Create A Foundry Project

<figure><img src="/files/Ag2FYWGoYtJBAJOOtNd3" alt=""><figcaption></figcaption></figure>

Like hardhat and truffle, foundry is a development environment for Ethereum smart contracts. And it is becoming more and more popular. Likewise, you can use foundry for developing and deploying smart contracts for KCC.

### Prerequisites&#x20;

* [Install foundry ](https://github.com/foundry-rs/foundry#installation)

{% hint style="info" %}
Foundry provides three command-line tools: forge, cast, and anvil. If you have successfully installed foundry, you can invoke any of those in your shell.&#x20;
{% endhint %}

### Create A New Project With Forge&#x20;

Let's create a new project called "my-nft" with the `forge` command from foundry:&#x20;

```bash
forge init my-nft
```

After executing the commands above, forge will create a directory named "my-nft". And there are several subdirectories and a file named "foundry.toml" in that directory:&#x20;

```
my-nft/
├── foundry.toml
├── lib
│   └── forge-std
├── script
│   └── Counter.s.sol
├── src
│   └── Counter.sol
└── test
    └── Counter.t.sol
```

### Add Configurations For KCC&#x20;

You can add two profiles to your foundry project by appending the following lines to the end of your `foundry.toml` file:&#x20;

```toml
[profile.kcc_main]
src = 'src'
out = 'out'
libs = ['lib']
# KCC has not implemented the London fork yet 
evm_version = 'berlin'
eth_rpc_url = 'https://rpc-mainnet.kcc.network'

[profile.kcc_testnet]
src = 'src'
out = 'out'
libs = ['lib']
# KCC has not implemented the London fork yet 
evm_version = 'berlin'
eth_rpc_url = 'https://rpc-testnet.kcc.network'
```

To test the configurations above, let's deploy the generated contract in the "Counter.sol" file to the KCC testnet: &#x20;

```bash
FOUNDRY_PROFILE=kcc_testnet  \
        forge create --private-key=xxxxxxxxxxx \
        --legacy  Counter
```

{% hint style="info" %}

* Forge reads the profile's name from the environment variable "FOUNDRY\_PROFILE".
* You should replace \`xxxxxxxxxxx\` with your own private key.&#x20;
  * BTW,  foundry also supports several other wallets: Keystore, mnemonic, and even Ledger.  And it is not wise to use a private key except in a test.
* You must use the `--legacy` option because KCC has not implemented EIP1559 yet.&#x20;
  {% endhint %}

If everything goes well, forge will print out the address of the deployed contract and the transaction hash for the deployment.&#x20;


---

# 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.kcc.io/developers/deploy-nfts/create-a-foundry-project.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.
