This is an introductory project that demonstrates various fundamentals of Web3 and SmartContract development.
Follow the below steps to set up the project
Start by installing Ganache
Ganache is an Ethereum simulator that makes developing Ethereum applications faster, easier, and safer.
brew install --cask ganache
- Open the Ganache application
- Create a new server
Install the TruffleSuite
npm install -g truffle@latest
Change directories to the blockchain
folder and install the node dependencies
cd blockchain
npm install
While in the blockchain
directory run the following to compile the contract
truffle compile
You should see something similar to this:
❯ truffle compile
Compiling your contracts...
===========================
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/TodoList.sol
> Artifacts written to /Users/markjtaylorroberts/Documents/Projects/eth-todo-list/blockchain/build/contracts
> Compiled successfully using:
- solc: 0.8.13+commit.abaa5c0e.Emscripten.clang
Deploy the compiled TodoList contract to Ganache by running the migrate command
truffle migrate
If you want to deploy again after making changes, you can bypass creating a new "migration" file by running
truffle migrate --reset
Open a truffle console to test your Contracts functions
truffle console
While in the console, create an instance of your contract
truffle(development)> todoList = await TodoList.deployed()
Inspect the contracts address
truffle(development)> todoList.address
Create a Todo item
truffle(development)> todoList.createTask("My task")
Get a list of your Todo items
truffle(development)> todoList.getOwnerTasks()
[
[
'0',
'My task',
false,
id: '0',
content: 'My task',
completed: false
]
]
This project comes equipped with a Web3 dApp built in react.
The project uses Chakra-ui for Components and Styles and the useDApp library for interacting with our Contract.
Start by changing directory to the app
folder.
cd app
npm install
npm start
In order to interact with our Contract from our WebApp, we'll need to add the Ganache network to MetaMask and import one of our Ganache accounts using the provided private key.
- Open MetaMask and add a network with the following properties
- Name:
Ganache
- New RPC Url: `http://127.0.0.1:7545
- Chain ID:
1337
- Currency Symbol:
ETH
- Name:
- Click Save
With the Ganache network added to MetaMask, we can now add one of our Ganache test accounts.
- Open the Ganache App (GUI)
- If "Accounts" isn't already active, click "Accounts".
- Next to one of your listed Ganache accounts, click the Key icon on the far right.
- Copy the selected accounts private key
- Open MetaMask
- Click the circular Identicon in the top-right corner of MetaMask
- Select "Import Account"
- Paste your Ganache account's private key and click "import"
With the web UI running, head over to http://localhost:3000
.
- Open MetaMask, switch to your test account, and change to your Ganache network.
- In the Todo UI, click "Connect To Wallet"
- Select your test account to connect with
After connecting MetaMask you should now see ~100ETH and a sub-string of your Address!
You can optionally edit and deploy your contract via Remix
npm install -g @remix-project/remixd