Skip to content

Commit

Permalink
Update 4. Updating and Deleting To-Do Items.md
Browse files Browse the repository at this point in the history
  • Loading branch information
munimmetaschool committed Aug 26, 2024
1 parent 592a427 commit 6cd9293
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Next, compile our smart contract by running the following command:
cargo build --target wasm32-unknown-unknown --release
```

![26.gif](Lesson%2021%20Bringing%20Your%20To-Do%20List%20to%20Life%20Creatin%20a1233499e256424f84d84c0406305ebb/26.gif)
![26.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/Building%20on%20Mantra%20-%20C2/5.%20Implementing%20Functions,%20Contract%20Managem/4.%20Updating%20and%20Deleting%20To-Do%20Items/26.gif?raw=true)

Now before we upload the `cw_to_do_list.wasm` to the Testnet , we will need to optimize it.

Expand All @@ -188,7 +188,7 @@ docker run --rm -v "$(pwd)":/code \
cosmwasm/optimizer:0.16.0
```

![27.gif](Lesson%2021%20Bringing%20Your%20To-Do%20List%20to%20Life%20Creatin%20a1233499e256424f84d84c0406305ebb/27.gif)
![27.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/Building%20on%20Mantra%20-%20C2/5.%20Implementing%20Functions,%20Contract%20Managem/4.%20Updating%20and%20Deleting%20To-Do%20Items/27.gif?raw=true)

## Deploying the Contract

Expand All @@ -207,7 +207,7 @@ CODE_ID=$(mantrachaind query tx --type hash $TX_HASH --node https://rpc.hongbai.
echo $CODE_ID
```

![28.gif](Lesson%2021%20Bringing%20Your%20To-Do%20List%20to%20Life%20Creatin%20a1233499e256424f84d84c0406305ebb/28.gif)
![28.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/Building%20on%20Mantra%20-%20C2/5.%20Implementing%20Functions,%20Contract%20Managem/4.%20Updating%20and%20Deleting%20To-Do%20Items/28.gif?raw=true)

## Instantiating the Contract

Expand All @@ -217,7 +217,7 @@ To instantiate our smart contract, use the `mantrachaind tx wasm instantiate` co
mantrachaind tx wasm instantiate $CODE_ID '{"owner": "wallet_address_here"}' --from wallet --label "cw-to-do-list" --node https://rpc.hongbai.mantrachain.io:443 --chain-id $CHAIN_ID --gas-prices 0.25uom --gas auto
```

![29.gif](Lesson%2021%20Bringing%20Your%20To-Do%20List%20to%20Life%20Creatin%20a1233499e256424f84d84c0406305ebb/29.gif)
![29.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/Building%20on%20Mantra%20-%20C2/5.%20Implementing%20Functions,%20Contract%20Managem/4.%20Updating%20and%20Deleting%20To-Do%20Items/29.gif?raw=true)

This command initializes the contract with your wallet address as the owner, using the specified code ID and network settings, and automatically calculates the gas limit and adjustment. Once the process completes, We can fetch the contract details using `mantrachaind` and store it inside `CONTRACT` for interaction

Expand All @@ -226,15 +226,15 @@ CONTRACT=$(mantrachaind query wasm list-contract-by-code $CODE_ID $NODE --output
echo $CONTRACT
```

![30.gif](Lesson%2021%20Bringing%20Your%20To-Do%20List%20to%20Life%20Creatin%20a1233499e256424f84d84c0406305ebb/30.gif)
![30.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/Building%20on%20Mantra%20-%20C2/5.%20Implementing%20Functions,%20Contract%20Managem/4.%20Updating%20and%20Deleting%20To-Do%20Items/30.gif?raw=true)

Copy the smart contract address and paste it into the `.env` file located in the `building-on-MANTRA-chain/interface/` directory.

## Interacting with the Frontend

To start our frontend, navigate to the `interface` directory, install all dependencies using `npm install`, and then run the development environment.

![31.gif](Lesson%2021%20Bringing%20Your%20To-Do%20List%20to%20Life%20Creatin%20a1233499e256424f84d84c0406305ebb/31.gif)
![31.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/Building%20on%20Mantra%20-%20C2/5.%20Implementing%20Functions,%20Contract%20Managem/4.%20Updating%20and%20Deleting%20To-Do%20Items/31.gif?raw=true)

Once the development server is up and running, you can access your application in your web browser by navigating to the localhost URL.

Expand All @@ -244,7 +244,7 @@ Once the development server is up and running, you can access your application i
- Add a Todo and use the the dropdown menu to select it’s priority. Click on the Add button and approve the transaction.
- You can now test out updating and deleting the todo using the clickable icons on the right.

![33.gif](Lesson%2021%20Bringing%20Your%20To-Do%20List%20to%20Life%20Creatin%20a1233499e256424f84d84c0406305ebb/33.gif)
![33.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/Building%20on%20Mantra%20-%20C2/5.%20Implementing%20Functions,%20Contract%20Managem/4.%20Updating%20and%20Deleting%20To-Do%20Items/33.gif?raw=true)

## Quick Check Point

Expand All @@ -260,8 +260,4 @@ git push

Congratulations! You've successfully supercharged your to-do list dApp with update and delete functionalities, giving users full control over their tasks on the MANTRA Chain. Not only that, but you've also learned how to interact with your contract from a frontend, making your dApp accessible and user-friendly.

With the completion of these essential features, you've officially built your first fully functional decentralized application on MANTRA Chain! Take a moment to celebrate this milestone, and get ready to dive deeper into the exciting world of CosmWasm development as we explore more advanced topics and build even more complex dApps in future lessons.

### Assignment

Share the address of the contract you have deployed for the complete Todo-list App.
With the completion of these essential features, you've officially built your first fully functional decentralized application on MANTRA Chain! Take a moment to celebrate this milestone, and get ready to dive deeper into the exciting world of CosmWasm development as we explore more advanced topics and build even more complex dApps in future lessons.

0 comments on commit 6cd9293

Please sign in to comment.