Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link
Intro to Predicates

Icon LinkPredicates 101: Building Stateless DeFi Applications

Predicates are Fuel's approach to stateless account abstraction. In the blockchain space, we are constantly faced with the exponential growth of state bloat that just isn't sustainable in the long term. In the Ethereum ecosystem, every contract deployed requires state storage on the blockchain indefinitely. To help with blockchain scalability, we need to consider different approaches to redefine state-minimized applications that are fundamental to the world of decentralized finance.

This tutorial will specifically concentrate on the predicate program type, one of the four program types in the Sway language and how we can solve this ever growing problem.

Icon LinkWhat are Predicates?

To define Predicates into one sentence:

Icon InfoCircle

Predicates are stateless programs that return true or false.

A predicate is represented by an Address type, identical to any EOA (Externally Owned Account) created by a private key. The bytecode of the program can be deterministically hashed and represented as an ordinary address, all calculated off-chain. Therefore, when this address contains assets, ANYONE can spend the assets locked behind the predicate if they can evaluate the predicate to be true. It might be helpful to think of the code as the private key to the wallet.

If this concept is still a bit unclear don't worry!, let's explore a simple example in the next part of the project setup.

📚 Sway Standard Library Icon Link: A native library equipped with useful types and methods.

🧑‍🔧 Fuelup Icon Link: The official Fuel toolchain manager aids in installing and managing different versions.

🦀 Fuel's Rust SDK Icon Link: Test and interact with your Sway contracts using Rust.

Fuel's TypeScript SDK Icon Link: Test and interact with your Sway contracts using TypeScript.