Algorand Challenge #04: Fix the Bug.

Check out the GitHub repository.

🚩 Challenge 4: How Do I Atomically Send 2 Payment Transactions? 🤔

I want to group 2 payment transactions using Algorand’s atomic transfers feature but it’s not working!

Inside of index.ts file, there is code that is trying to atomically group 2 payment transactions and synchronously send them using atomic transfers. The code is using the Algorand JavaScript SDK and the AlgoKit Utils TypeScript.

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 and show this error: TypeError: signer is not a function

Find out what is wrong and fix the bug.

💬 Meet other hackers working on this challenge and get help in the General Dev Discord Channel!

Checkpoint 1: 🧰 Prerequisites

  1. Install AlgoKit.
  2. Install Docker. It is used to run a local Algorand network for development.
  3. Install Node.JS / npm

Checkpoint 2: 💻 Set up your development environment

  1. Fork this repository.
  2. Clone the repository
cd [DIRECTORY_OF_YOUR_CHOICE]
git clone [FORKED_REPO_URL]
  1. Open the cloned repository with the code editor of your choosing.
  2. Setup Dev environment using AlgoKit. Run the below command inside of the challenge folder.
algokit bootstrap all

This command will install all dependencies and also generate a .env file for you.

Video walkthrough of forking and cloning this repository:

https://github.com/algorand-fix-the-bug-campaign/challenge-1/assets/52557585/acde8053-a8dd-4f53-8bad-45de1068bfda

Now you are ready to fix the bug!

Checkpoint 3: 🐞 Fix the bug 🧐

  1. Open Docker Desktop and launch Algorand localnet by running algokit localnet start in your terminal For more info click me!.
  2. Go to ./index.ts and read the comments on the file and fix the bug!
  3. After fixing the bug run the below command inside of the challenge folder:
npm run start
  1. If you see: The first payment transaction sent 1000000 microAlgos and the second payment transaction sent 2000000 microAlgos in the console, you successfully fixed the bug! 😆

References

😰 Are you struggling?

atc.addTransaction() takes in a transactionWithSigner object as the parameter. You can get the signer of an account using the makeBasicAccountTransactionSigner function from the Algorand JavaScript SDK.

Checkpoint 4: 💯 Submit your answer

  1. After fixing the bug, push your code to your forked Github repo and make a PR to the original repo.
  2. Inside the PR include:
    1. What was the problem?
    2. How did you solve the problem?
    3. Screenshot of your terminal showing the result of running index.ts file.

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! This was the final challenge of the 1st season of #AlgoCodingChallenge. Be on the lookout for the 2nd season of #AlgoCodingChallenge!

Solution:

  1. What was the bug?

The error shown was: TypeError: signer is not a function. Also, according to Visual Studio Code: Type Account' is not assignable to type ‘TransactionSigner’.

  1. How did you fix the bug?

I used the makeBasicAccountTransactionSigner function.

cert

Related Posts