Asset-Oriented Programming
Scrypto is built on asset-oriented programming — a paradigm where digital assets are first-class primitives managed by the Radix Engine, not arbitrary integers in a smart contract's storage.
In Solidity, a token is a mapping of addresses to balances inside a contract. Transferring tokens means calling a function that modifies that mapping. Bugs in this logic cause real losses — reentrancy, integer overflow, and unauthorized access.
In Scrypto, tokens are resources — objects with physical-like properties enforced by the engine. They cannot be duplicated, destroyed without authorization, or exist outside a container. The runtime guarantees that every resource is accounted for at the end of every transaction.
Blueprints, Components, and Packages
Scrypto's object model has three levels:
| Concept | Analogy | Description |
|---|---|---|
| Package | Library / crate | Deployment unit containing one or more blueprints. Deployed once, referenced by address. |
| Blueprint | Class / template | Defines state shape and methods. Contains no state itself — it's a template. |
| Component | Instance / object | A live instantiation of a blueprint. Holds state, owns resources in vaults. |
A single blueprint can be instantiated many times — each component is independent with its own state and resource holdings.
Code Structure
use scrypto::prelude::*;
#[blueprint]
mod my_blueprint {
struct MyBlueprint {
// State fields — persisted between transactions
my_vault: Vault,
count: u64,
}
impl MyBlueprint {
// Functions: called on the blueprint (no &self)
// Used for instantiation
pub fn instantiate() -> Global<MyBlueprint> {
Self { /* ... */ }
.instantiate()
.prepare_to_globalize(OwnerRole::None)
.globalize()
}
// Methods: called on a component (&self or &mut self)
pub fn get_count(&self) -> u64 {
self.count
}
pub fn increment(&mut self) {
self.count += 1;
}
}
}The #[blueprint] macro handles serialization, state management, and ABI generation. You write plain Rust structs and methods.
How Radix Engine Differs from EVM
| Aspect | EVM (Solidity) | Radix Engine (Scrypto) |
|---|---|---|
| Assets | Contract storage mappings | First-class resources with engine-enforced rules |
| Transfer | Call a function that mutates state | Move a bucket between vaults |
| Authorization | msg.sender checks | Badge-based access rules |
| Reentrancy | Must be guarded manually | Impossible — resources move, not references |
| Composability | External calls with ABI encoding | Native cross-component calls via transaction manifests |
| Scaling | Single global state | Shard-aware via Cerberus |
Key Takeaways
- Resources are real — they behave like physical objects, not database entries
- Blueprints are templates — they define behavior but hold no state
- Components are instances — each with independent state and resource vaults
- The engine enforces safety — reentrancy, double-spend, and overflow bugs are prevented at the runtime level
