- Open a Git Bash (in Windows) or a terminal (in Mac).
- Create a folder
Solidityand enter it.mkdir Solidity cd Solidity - Initialize a Foundry project.
forge init hello - Enter the new folder and open Visual Studio Code.
cd hello code . - Move src/Counter.sol elsewhere (e.g., the
origfolder). Editsrc/Hello.sol. (You can copy this file from/smart_contracts/code/solidity/hello/src/Hello.sol.) - Move test/Counter.t.sol elsewhere (e.g., the
origfolder). Edittest/Hello.t.sol. (You can copy this file from/smart_contracts/code/solidity/hello/test/Hello.t.sol.) - Move test/Counter.s.sol elsewhere (e.g., the
origfolder). Editscript/Hello.s.sol. (You can copy this file from/smart_contracts/code/solidity/hello/script/Hello.s.sol.) - Test the contract.
forge test -vv - Build the contract.
forge build - Deploy the contract using command (and using your private key).
forge create src/Hello.sol:Hello --rpc-url http://127.0.0.1:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --broadcast - Alternatively, deploy the contract using deployment script (and using your private key).
forge script script/Hello.s.sol --rpc-url http://127.0.0.1:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --broadcast
- Open a Git Bash (in Windows) or a terminal (in Mac).
- Enter the folder
Web.cd Web - Create a folder
helloand enter it.mkdir hello cd hello - Initialize an npm project.
npm init - Install Web3.js.
npm install web3 - Edit
hello.js. (You can copy this file from/smart_contracts/code/web/hello/hello.js.)code . - View the result.
node hello - Interact with the contract uisng the
castcommand.cast call <contract-address> "greet()(string)" --rpc-url http://127.0.0.1:8545 cast call <contract-address> "getMaxUint256()(uint256)" --rpc-url http://127.0.0.1:8545 cast call <contract-address> "sumUpTo(uint256)(uint256)" 100 --rpc-url http://127.0.0.1:8545
- Open a Git Bash (in Windows) or a terminal (in Mac).
- Enter the folder
Web.cd Web - Create a React + Vite app.
npm create vite@latest hello-app -- --template react - Enter the new folder and install Vite.
cd hello-app npm install - Install Web3.js.
npm install web3 - Backup "src/App.jsx" to "src/App.jsx.ORIG".
mv src/App.jsx src/App.jsx.ORIG - Edit
src/App.jsx. (You can copy this file from/smart_contracts/code/web/hello-app/src/App.jsx.)(Run the editor at the root folder of hello-app.)code . - Put
go.cjsinto your app root (i.e., hello-app). (You can copy this file from/smart_contracts/code/web/hello-app/go.cjs.) - Run
go.cjsto extract the contract's ABI and address.mkdir src/abi node go.cjs - View the web page.
npm run dev
Notes:
- Install the
React Developer Toolsplugin in your browser for advanced debugging. forge cleancan remove the build artifacts and cache directories.

