Skip to content

Repository files navigation

A simple blockchain(Solidity) calculator: Features: 1. Addition 2. Multiplication 3. Subtraction 4. Division

Start the blockchain-calculator locally using Anvil: First, have the Calculator smart contract ready using Foundry. So, use a local blockchain to deploy it. Foundry's Anvil is perfect for this. Anvil runs a local node, so I should mention starting that.

Once Anvil is running, you can deploy the contract to the local network. Using Forge's create command with the RPC URL from Anvil makes sense. You'll get a contract address.

"Step 1 - type "anvil" in terminal 1

Next, the frontend. Use React app and connect it to the local blockchain. But browsers usually connect to mainnets or testnets via MetaMask. So, configure MetaMask to point to the local Anvil network. Adding a custom network with the Anvil RPC URL and chain ID 31337 is key here. Also, they'll need some test ETH, which Anvil provides private keys with funds.

Step 2 - https://medium.com/@dehvcurtis/day-1-introduction-to-solidity-anvil-d0647229215b (Read Step 6)

Then, in the frontend code, replace the contract address and ABI with the local ones. Forge can generate the ABI, so I should remind them to export it. Testing the UI involves running the app, connecting MetaMask, and performing transactions. Since it's local, transactions should be fast and free.

Possible issues you might run into like MetaMask not connecting, wrong contract address, or missing ABI. I should list common troubleshooting steps: checking the RPC URL, ensuring the contract is deployed, and the ABI is correctly imported.

Also, mention that after deployment, interacting with the contract through the UI should emit events, which the frontend can listen for. But since it's local, they might not see transaction on a block explorer, so checking the console logs or using Foundry's logs might help.

Putting it all together: start Anvil, deploy contract, set up MetaMask, update frontend config, run the app, test transactions.

Step 3 - to run the frontend - navigate to cd/solidity-calc-frontend and run "npm start"

The codebase has the following issues: npm start - works correctly but nothing shows up on the frontend, issue will be fixed in a few days

About

Mini Blockchain Projects

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages