Smart Contracts Built for
the AI Era.
Cadence is a safe, resource-oriented programming language built for the Flow blockchain. Designed for digital ownership and optimized for AI-driven development.
Architectural Pillars
Resource Oriented
Assets live in account storage as first-class objects. They cannot be lost, duplicated, or forgotten. The type system enforces physical-world scarcity.
Capabilities
Security via object-capabilities. Authority is granted by holding a reference to a resource, removing the need for error-prone permission lists.
// The system enforces ownership
access(all) resource NFT {
access(all) let id: UInt64
init() { self.id = self.uuid }
}
// Moves are explicit and safe
access(all) fun transfer(token: @NFT) {
// '@' denotes a resource that MUST be handled
Receiver.deposit(token: <- token)
}LEDGER VS. RESOURCES
Centralized Accounting
Assets are just entries in a contract's private dictionary. To move value, you update two numbers. This "ledger" model is prone to reentrancy bugs.
function transfer(address to, uint val) {
balances[msg.sender] -= val;
balances[to] += val;
}
Direct Ownership
Tokens live in the user's account as vault resources. Withdrawing creates a new resource the compiler tracks: it must be deposited or explicitly destroyed — it cannot be silently lost or duplicated.
auth(FungibleToken.Withdraw) &FlowToken.Vault>
(from: /storage/flowTokenVault)!
let payment <- vault.withdraw(amount: 10.0)
receiver.deposit(from: <- payment)
// payment: must be deposited, cannot be duplicated