Introduction
Once your development environment is set up, the next step is understanding the Scrypto development workflow: creating packages, writing blueprints, building to WebAssembly, and testing locally. Radix provides two complementary testing approaches β the resim simulator for interactive exploration and the scrypto-test framework for automated testing.
Package Structure
A Scrypto package is a standard Rust crate with Scrypto-specific dependencies. When you run scrypto new-package my-dapp, you get:
my-dapp/
βββ Cargo.toml # Dependencies (scrypto crate)
βββ src/
β βββ lib.rs # Blueprint definitions
βββ tests/
βββ lib.rs # Test suiteThe src/lib.rs file contains one or more blueprints β reusable templates that define the structure and logic of on-ledger components. Each blueprint is annotated with the #[blueprint] macro and contains a struct (state) and an impl block (functions and methods).
Building
Compile your package to WebAssembly with:
scrypto buildThis produces a .wasm binary and a .rpd (Radix Package Definition) file in the target/ directory. The .rpd contains the package's ABI β the blueprint names, functions, methods, and their type signatures β which the Radix Engine uses to validate calls at runtime.
Interactive Testing with resim
The Radix Engine Simulator (resim) is a local ledger emulator that lets you publish packages, instantiate components, and call methods without connecting to any network. It is invaluable for rapid iteration.
Core Commands
# Reset simulator state
resim reset
# Create a new account (returns address, public key, private key, owner badge)
resim new-account
# Set the active account
resim set-default-account <account_address> <private_key> <owner_badge_address>
# Publish a package (returns package address)
resim publish .
# Call a blueprint function (e.g. instantiate a component)
resim call-function <package_address> <BlueprintName> <function_name> [args...]
# Call a method on an instantiated component
resim call-method <component_address> <method_name> [args...]
# Inspect an entity's state
resim show <address>Typical Workflow
resim resetβ start with a clean ledgerresim new-accountβ create a test accountresim publish .β deploy your packageresim call-functionβ instantiate a component from your blueprintresim call-methodβ interact with the componentresim showβ inspect state, balances, and vaults
Automated Testing with scrypto-test
While resim is great for exploration, production packages need automated tests. Radix provides two testing frameworks:
Unit Testing: scrypto-test
The scrypto-test framework uses an invocation-based approach β you call blueprint functions and methods directly in Rust, receiving actual Bucket and Proof objects that you can assert against. At its core is the TestEnvironment struct, which encapsulates a self-contained Radix Engine instance.
use scrypto_test::prelude::*;
#[test]
fn test_instantiation() {
let mut env = TestEnvironment::new();
let package = Package::compile_and_publish(".", &mut env).unwrap();
// Call functions, assert on returned buckets/proofs
}Key utilities include BucketFactory and ProofFactory for creating test resources, with strategies like CreationStrategy::DisableAuthAndMint for bypassing auth in test contexts.
Integration Testing: TestRunner
The TestRunner is an in-memory ledger simulator where you interact as an external user submitting transactions. It applies all the same costing limits and auth checks as the real network, making it ideal for end-to-end testing.
Run all tests with:
scrypto testThis wraps cargo test with the correct Scrypto feature flags and environment.
