Create A Foundry Project
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 DCC.
Prerequisites
Create A New Project With Forge
Let's create a new project called "my-nft" with the forge
command from foundry:
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:
my-nft/
├── foundry.toml
├── lib
│ └── forge-std
├── script
│ └── Counter.s.sol
├── src
│ └── Counter.sol
└── test
└── Counter.t.sol
Add Configurations For DCC
You can add two profiles to your foundry project by appending the following lines to the end of your foundry.toml
file:
[profile.dcc_main]
src = 'src'
out = 'out'
libs = ['lib']
# DCC has not implemented the London fork yet
evm_version = 'berlin'
eth_rpc_url = 'https://rpc.docoin.shop'
[profile.dcc_testnet]
src = 'src'
out = 'out'
libs = ['lib']
# DCC has not implemented the London fork yet
evm_version = 'berlin'
eth_rpc_url = 'https://rpc.docoin.shop'
To test the configurations above, let's deploy the generated contract in the "Counter.sol" file to the DCC testnet:
FOUNDRY_PROFILE=dcc_testnet \
forge create --private-key=xxxxxxxxxxx \
--legacy Counter
If everything goes well, forge will print out the address of the deployed contract and the transaction hash for the deployment.
Last updated