Algorand Challenge #03: Fix the Bug.
Check out the GitHub repository.
🚩 Challenge 3: My AppClient is Broken! 😭
I want to instantiate an app client to deploy and interact with my smart contract but it’s not working!!
This project includes a simple helloWorld
smart contract written with TEALScript inside of ./contract/helloWorld.algo.ts
file. The smart contract is already compiled with artifacts generated inside of the ./contracts/artifacts
folder and the application typed client inside of ./contracts/clients/helloWorldClient.ts
file.
Artifacts: autogenerated assets (TEAL contract code, ABI spec, source mapping) for your smart contract. Application Typed Client: autogenerated client used to easily deploy / interact with Algorand smart contract.
The index.ts
file in the root level is a script that deploys the helloWorld
smart contract and calls the helloWorld
method.
However, if you try to run the index.ts
file after going into the challenge
directory, opening Docker Desktop, and then running:
algokit bootstrap all
algokit localnet start
npm run start
it will fail.
Find out what is wrong and fix the bug.
💬 Meet other hackers working on this challenge and get help in the AlgoKit Discord Channel!
Checkpoint 1: 🧰 Prerequisites
- Install AlgoKit.
- Install Docker. It is used to run a local Algorand network for development.
- Install Node.JS / npm
Make sure to install these 3 prerequisites before continuing!
Checkpoint 2: 💻 Set up your development environment
- Fork this repository.
- Clone the repository
cd [DIRECTORY_OF_YOUR_CHOICE]
git clone [FORKED_REPO_URL]
- Open the cloned repository with the code editor of your choosing.
Video walkthrough of forking and cloning this repository:
Now you are ready to fix the bug!
Checkpoint 3: 🐞 Fix the bug 🧐
- Open Docker Desktop and launch Algorand localnet by running
algokit localnet start
in your terminal For more info click me!. - Go to
./contracts/helloWorld.algo.ts
to read thehelloWorld
TEALScript smart contract and understand what it does. - Go to
./index.ts
and read the comments on the file and fix the bug! - After fixing the bug run the below command inside the
challenge
directory:
npm run start
If you see something like the image below, you have successfully fixed the bug! Congratulations 😆
😰 Are you struggling? Here is a hint for you: https://developer.algorand.org/docs/get-details/algokit/features/generate/?from_query=algokit%20utils#1-typed-clients
Checkpoint 4: 💯 Submit your answer
- After fixing the bug, push your code to your forked Github repo and make a PR to the original repo.
- Inside the PR include:
- What was the problem?
- How did you solve the problem?
- A screenshot of your terminal that shows the console.log
Checkpoint 5: 🏆 Claim your certificate of completion NFT! 🎓
The Algorand Developer Relations team will review the submission and “approve” the PR by labeling it Approved
. Once it’s approved, we will share the magic link to claim your certificate of completion NFT in the comment of the PR!
The certificate of completion NFT is a verifiable credential minted on the GoPlausible platform that follows the W3C standard for certificates and OpenBadges standard for badges.
🎉 Congratulations on completing the challenge Algodev! Now on to the next one 💪
Solution:
-
What was the bug?
- In the creator address it was missing the addr property.
- A wrong function was being returned in index.ts
-
How did you fix the bug?
Following the documentation I fixed the bugs by setting the correct creatorAddress to “deployer.addr” and changing indexer to “algod”, which is the correct function. Also changed “YOUR_NAME” to my nickname.