RADIX WikiRADIX Wiki

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:

ConceptAnalogyDescription
PackageLibrary / crateDeployment unit containing one or more blueprints. Deployed once, referenced by address.
BlueprintClass / templateDefines state shape and methods. Contains no state itself — it's a template.
ComponentInstance / objectA 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

AspectEVM (Solidity)Radix Engine (Scrypto)
AssetsContract storage mappingsFirst-class resources with engine-enforced rules
TransferCall a function that mutates stateMove a bucket between vaults
Authorizationmsg.sender checksBadge-based access rules
ReentrancyMust be guarded manuallyImpossible — resources move, not references
ComposabilityExternal calls with ABI encodingNative cross-component calls via transaction manifests
ScalingSingle global stateShard-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

Next Steps