Create A Foundry Project
Last updated
Last updated
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.
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.
Let's create a new project called "my-nft" with the forge
command from foundry:
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:
You can add two profiles to your foundry project by appending the following lines to the end of your foundry.toml
file:
To test the configurations above, let's deploy the generated contract in the "Counter.sol" file to the KCC testnet:
Forge reads the profile's name from the environment variable "FOUNDRY_PROFILE".
You should replace `xxxxxxxxxxx` with your own private key.
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.
If everything goes well, forge will print out the address of the deployed contract and the transaction hash for the deployment.