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.

Article Thumbnail

Stateful Smart Contracts, Rekeying, and Fast Catchup

BetaNet Upgrade Status

BetaNet, TestNet, and MainNet upgrades complete. See Forum Announcement.

On Wednesday, August 5th, a protocol upgrade was released to BetaNet introducing three brand new features to the Algorand protocol. This article will explain what these features are and point you to new documentation on how to use them. We look forward to feedback from the developer community on these new features and their documentation. Post your comments and questions on the Algorand forums !

The new features are…
- Stateful Smart Contracts
- Rekeying
- Fast Catchup

Stateful Smart Contracts

Stateful Smart Contracts are the next evolution of Algorand’s Layer-1 smart contract technology. Build applications that store state on-chain and combine them with all of Algorand’s other Layer-1 technologies (like Atomic Transfers and Algorand Standard Assets) to create very powerful applications, like running your own auction or creating a highly customized security token.

Here’s how I recommend getting started:

  1. See the re-organized Smart Contract section. There is now a sub-section for Stateless and Stateful Smart Contracts, respectively. The execution conditions of these smart contracts are different but they both use the same underlying Smart Contract language called TEAL.
  2. Read the full technical documentation on Stateful Smart Contracts and read this guide to learn how to create your first stateful application!
  3. There is also a new Guide to Building Applications on Algorand, which shows you how to compose Algorand’s Layer-1 features to create highly sophisticated applications using features that ensure speed, security, and scalability.

Info

A note on terminology: Stateful Smart Contracts may also be referred to as “stateful applications”. This is connected to their corresponding transaction type, which is denoted as an application transaction. However, “applications” can also refer to the more traditional concept of a full user-facing application, which may include stateful smart contracts (i.e. “stateful applications”), but may also include any combination of stateless smart contracts, assets, atomic transfers, and any other features.

Rekeying

Alice generates an account on Algorand that she will use as her personal hot wallet. This account is identified by a public address and Alice holds the corresponding private spending key. Alice gives her public address to various third parties so that she may receive Algos and other assets from them now and in the future. She also uses her address to pass KYC/AML and invest in a real estate project.

Now let’s say Alice believes that her private spending key may have been compromised or she just wants to maintain good security practices and rotate her keys periodically. The problem is, if she changes her spending key, her public address will change too and she will need to update every third party she has interacted with to provide her new address. What a hassle!

Introducing Rekeying!…

Instead, Alice can simply issue a special transaction that registers a new private spending key as the authorization method for her existing public address. Just like that, she can maintain high security on her account and conveniently maintain her address identifier across all the platforms she has interacted with. If she wanted to, she could also rekey her account to a multisignature account or even a smart contract account!

Rekeying has many uses beyond just simplifying good security practices. Another example is the ability to have some other party create an account, perhaps load it up with some assets, and then fully transfer ownership over to someone else.

Read all about rekeying here.

Fast Catchup

Last but not least, let’s talk about how to get connected to BetaNet so you can try out these new features! There are several options. You can run your own node, use sandbox, or connect via an API service like Purestake. The problem with the first option is that if you are spinning up a node from scratch, you are required to wait for the node to sync with the rest of the network before you can send transactions. Syncing requires that the node verifies every block in the history of the blockchain, which can take hours or days, depending on how long the history of the blockchain is. If you are an application developer who just wants to start using the new protocol features, this is less than ideal.

Introducing Fast Catchup!…

Instead of waiting for days for your node to sync, use fast catchup and sync in minutes! This feature is available now and you do not have to wait for the upgrade to complete. Read the Sync with Fast Catchup docs to get started.

Or, simply run the following after you install a node:

% CATCHPOINT=$(curl https://algorand-catchpoints.s3.us-east-2.amazonaws.com/channel/betanet/latest.catchpoint)
% goal node catchup $CATCHPOINT -d <betanet-data>

Check the status to watch it catchup:

% goal node status -d <betanet-data>

Sample Output:

Last committed block: 5084087
Sync Time: 11.0s
Catchpoint: 5080000#Z2Z7OESROGAE5OMEGY4SQ2R4C4V35B45L7XLPT6TL5SFUXGU2MKQ
Catchpoint total accounts: 1246
Catchpoint accounts processed: 1246
Catchpoint total blocks: 1000
Catchpoint downloaded blocks: 58
Genesis ID: betanet-v1.0
Genesis hash: mFgazF+2uRS1tMiL9dsj01hJGySEmPN28B/TjjvpVW0=

And run it again after several minutes to see that your node is all caught up:

Last committed block: 5084163
Time since last block: 0.3s
Sync Time: 0.0s
Last consensus protocol: https://github.com/algorandfoundation/specs/tree/e5f565421d720c6f75cdd186f7098495caf9101f
Next consensus protocol: https://github.com/algorandfoundation/specs/tree/3a83c4c743f8b17adfd73944b4319c25722a6782
Round for next consensus protocol: 5107702
Next consensus protocol supported: true
Last Catchpoint: 5080000#2BNEE2WRZU3B55FKTH4STF2OIWEN47LKYMNOTPZY2GHQTQBAA76Q
Genesis ID: betanet-v1.0
Genesis hash: mFgazF+2uRS1tMiL9dsj01hJGySEmPN28B/TjjvpVW0=

Sign up for the Algorand Developer Newsletter to learn about all the latest features on Algorand!