Scrypto
Language for building DeFi apps on Radix.
Terminology
- Package: A collection of blueprints, compiled and published as a single unit.
- Blueprint: A template that describes the common behavior and structure of its instances.
- Component An instance of a blueprint, which lives in ledger state.
- Function: A set of statements to perform a specific task.
- Method: A function associated with a component.
- ResourceDef: The definition of a resource, including metadata, supply and mint auth.
- Bucket: A transient resource container.
- Vault: A persistent resource container in ledger state.
Installation
- Install Rust
- Windows:
- Download and install
rustup-init.exe
- Install "Desktop development with C++" with Build Tools for Visual Studio 2019
- Download and install
- Linux and macOS:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Windows:
- Enable
cargo
in the current shell:- Windows:
- Start a new PowerShell
- Linux and macOS:
source $HOME/.cargo/env
- Windows:
- Add WebAssembly target
rustup target add wasm32-unknown-unknown
- Install simulator
git clone [email protected]:radixdlt/radixdlt-scrypto.git cd radixdlt-scrypto cargo install --path ./simulator
- (Optional) Open Scrypto documentation for later use
./doc.sh
Note: For preview release, do not delete or move the repository after installation. It will be used when resolving dependencies of Scrypto packages.
Getting Started
If you want a quick walkthrough of how to deploy and run some code, please see the First Steps tutorial. If you prefer to soldier through on your own, keep reading below.
Writing Scrypto Code
- Start by creating a new package:
scrypto new-package
cd
- Check out the files under your current directory:
- Source code is within
src/lib.rs
; - Test code is within
tests/lib.rs
.
- Build your package:
scrypto build
- Run tests:
scrypto test
Playing with Radix Engine
Action | Command |
---|---|
To create an account | resim new-account |
To change the default account | resim set-default-account
|
To create a token with fixed supply | resim new-token-fixed
|
To create a token with mutable supply | resim new-token-mutable
|
To create a badge with fixed supply | resim new-badge-fixed
|
To create a badge with mutable supply | resim new-badge-mutable
|
To mint resource | resim mint
|
To transfer resource | resim transfer
|
To publish a package | resim publish
|
To call a function | resim call-function
|
To call a method | resim call-method
|
To export the ABI of a blueprint | resim export-abi
|
To show info about an address | resim show
|
Note: The commands use the default account as transaction sender.
Project Layout
sbor
: The binary data format used by Scrypto.sbor-derive
: Derives for encoding and decoding Ruststruct
andenum
.scrypto
: Scrypto standard library.scrypto-abi
: Scrypto blueprint ABI.scrypto-derive
: Derives for defining and importing Scrypto blueprints.radix-engine
: The Scrypto execution engine.simulator
: A simulator that run Scrypto code on a filesystem based ledger.examples
: Scrypto examples.