Using Foundry
Last updated
Last updated
Foundry is a smart contract development toolchain that manages your dependencies, compiles your project, runs tests, deploys, and lets you interact with the chain from the CLI and via Solidity scripts.
See the finished code at
See the chapter in the Foundry Book.
You can use "cast wallet new" to create a ThunderCore compatible wallet.
Here we name our newly created wallet deployer by moving the encrypted keystore file generated by "cast":
Foundry generates standard encrypted Ethereum keystore files under $HOME/.foundry/keystores
The format is
See
Private keys in the keystores can be exported with:
You'll need some gas tokens to deploy contracts.
To start a new project with Foundry, use forge init:
The src folder may already contain Counter.sol, a minimal Solidity contract.
Edit foundry.toml to contain:
Run the command forge build to build the project.
And test the build with "forge test".
Edit script/Counter.s.sol and add "new Counter()" at the end of run():
Use "forge script" to deploy your contract to ThunderCore:
Copy the address of your newly deployed contract from the output. Then go to the ThunderCore Blockchain Explorer, and paste the address in the Search by address field.
We can read the Counter value via cast call:
We can increment the Counter value via "cast send":
After a successful transaction that calls increment , reading the counter value again should now return 1 instead of 0.
In this guide, we've accomplished:
Created a new wallet in the Foundry keystore named deployer ($HOME/.foundry/deployer)
Obtained funds for gas to the deployer account
Created a new Foundry project
Configured that project for ThunderCore via foundry.toml
Deployed our contract to the ThunderCore blockchain
Interacted with our contract to read and write information
by using the `ethkey` utility from .
To test on ThunderCore testnet, you can get some testnet tokens from ThunderCore Testnet Faucet
For ThunderCore mainnet, see
Mainnet:
Testnet:
And that's the basics of how to develop on ThunderCore via Foundry! Remember the finished code is available at