Create Publication

We are looking for publications that demonstrate building dApps or smart contracts!
See the full list of Gitcoin bounties that are eligible for rewards.

Smart Contract Rookie

Changing Challenge SDK

You are about to change this challenge’s SDK to .
You current progress will not be lost.

Challenges

Smart Contract Rookie

Smart Contract Rookie Challenge Badge NFT

Smart Contract Rookie

Deploy a basic smart contract

rookie

In this task, you'll be deploying a smart contract.
On Algorand smart contracts have two distinct parts, the approval program (approval.teal) and the clear state program (clear.teal). The majority of the logic will typically be in the approval program, but the clear state program is there for users to call in the event that they want to forcefully "Opt Out" of the contract and free up any minimum balance requirement they may have had associated with it. A clear state transaction cannot fail even if the logic fails.

The approval program in this challenge is relatively simple. The first time it's deployed it jumps to the "setup" branch, where it stores the first application argument you provided into a global state called "access_code". Now on subsequent calls, you must provide the same argument as it's compared to be the same. If the comparison is successful, the smart contract will increment a "counter" in global state. Note that in this task the code for the contract is already written.

A smart contract is required to be compiled down to bytecode before being submitted to the network. Depending on how much global and/or local state data the smart contract uses, the schema must be configured and provided with the rest of the transaction parameters (the approval program provided requires just 1 global byteslice and 1 global int). Once the transaction has been successfully committed to a block, the application ID can be found and can be used to further calculate the application account address. Further calls to the now deployed smart contract can be made using the application ID.

Prepare for the challenge

The documentation above explains the details of smart contracts and how the SDKs can be used to deploy and call them.

You will complete the challenge with our partner Replit in a new tab. Fork the Replit using the 'Fork Replit' button in the righthand corner to begin. If this is your first challenge, you will need to create a Replit account before forking the challenge code.

In this challenge, you need to:

  • Compile the smart contract to bytecode
  • Construct an application call transaction with the correct parameters
  • Deploy the smart contract and identify the application ID
  • Call the smart contract with the correct parameters, incrementing the counter

Join Discord

Check out our Discord channel, where you can communicate with other Algorand developers.

Visit Discord