.. | ||
projects/local-private-network | ||
README.md |
Foundry README
Overview
This document will go through the steps needed to test using Foundry. Currently, we use Foundry in the following capacity.
- Create a private network with our internal version of Geth.
- Deploy a smart contract to the private network.
- Test the smart contract on the private network.
- Create a transaction on the private network.
Steps
The steps to create a new project are as follows.
1. Creating New Project
cd foundry/projects
.- Create a directory that captures your project:
mkdir local-private-network; cd local-private-network
. - Create a new foundry project:
forge init stateful
. - Follow the foundry documentation for writing smart contract tests.
2. Deployments
You can choose to have custom deployments for your workflow. However, it is recommended to utilize Docker.
Existing Projects
Below, you can find existing projects and their descriptions.
local-private-network
The purpose of this project is as follows:
- Compile the geth from the local source.
- Build a docker container with
ipld-eth-db
and another container for thelocal-private-network
. - Run the compiled version of geth.
- Deploy a smart contract to the private blockchain.
- Trigger a transaction on the newly deployed smart contract.
Using This Project
If you want to test your local geth code, do the following:
- cd
foundry/projects/local-private-network
. ./wrapper.sh
- This script will do all the heavy lifting for you.- Keep an eye out for the outputs from the docker container.
- Enter the docker container and do as you please.
- If you want to change your geth code, you will have to run
./wrapper.sh
for subsequent runs. - If you do not change your geth code, you have to run:
docker-compose up --build
.
Key Notes:
- The command to deploy the smart contract is:
forge create --keystore $ETH_KEYSTORE_FILE --rpc-url [http://127.0.0.1:8545](http://127.0.0.1:8545/) --constructor-args 1 --password "" --legacy /root/stateful/src/Stateful.sol:Stateful
- The command to interact create a transaction is:
cast send --keystore $ETH_KEYSTORE_FILE --rpc-url [http://127.0.0.1:8545](http://127.0.0.1:8545/) --password "" --legacy $DEPLOYED_ADDRESS "off()"
- The
Dockerfile
compilescast
andforge
. - The
foundry/projects/local-private-network/deploy-local-network.sh
file does most heavy lifting. It spins up geth and triggers various events. - The
foundry/projects/local-private-network/start-private-network.sh
file triggersdeploy-local-network.sh
. This file runs all the tests. - The
geth
node will stay running even after the tests are terminated.