Language for building DeFi apps on Radix.
Documentation: https://docs-babylon.radixdlt.com/main/scrypto/introduction.html
The code in this repository is released under the Radix License, Version 1.0 and includes modified third party work which is reproduced here pursuant to the Apache 2.0 licensing regime. Where third party software has been used this is identified together with the appropriate open-source licence.
Binaries, including libraries, CLIs and docker images, are licensed under the Radix Software EULA.
- Install Rust - this requires Rust 1.70+ (if rust is already installed, upgrade with
rustup update
)- Windows:
- Download and install
rustup-init.exe
- Install "Desktop development with C++" with Build Tools for Visual Studio 2019
- Install LLVM 13.0.1 (make sure you tick the option that adds LLVM to the system PATH)
- Enable git long path support:
git config --system core.longpaths true
- Download and install
- macOS:
- Make sure you have the xcode command line tools:
xcode-select --install
. - Install cmake:
brew install cmake
- Install the Rust compiler:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Make sure you have the xcode command line tools:
- Linux:
- Make sure a C++ compiler, LLVM and cmake is installed (
sudo apt install build-essential llvm cmake
). - Install the Rust compiler:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Make sure a C++ compiler, LLVM and cmake is installed (
- 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 https://github.com/radixdlt/radixdlt-scrypto.git cd radixdlt-scrypto cargo install --path ./simulator
- (Optional) Open Scrypto documentation for later use
./doc.sh
If you want a quick walkthrough of how to deploy and run some code, please see the Run Your First Project tutorial. If you prefer to soldier through on your own, keep reading below.
- Start by creating a new package:
scrypto new-package <package_name>
cd <package_name>
- 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
Action | Command |
---|---|
Create an account | resim new-account |
Change the default account | resim set-default-account <account_address> <account_public_key> |
Create a token with fixed supply | resim new-token-fixed <amount> |
Create a token with mutable supply | resim new-token-mutable <minter_resource_address> |
Create a badge with fixed supply | resim new-badge-fixed <amount> |
Create a badge with mutable supply | resim new-badge-mutable <minter_resource_address> |
Mint resource | resim mint <amount> <resource_address> <minter_resource_address> |
Transfer resource | resim transfer <amount> <resource_address> <recipient_component_address> |
Publish a package | resim publish <path_to_package_dir> |
Call a function | resim call-function <package_address> <blueprint_name> <function> <args> |
Call a method | resim call-method <component_address> <method> <args> |
Export the definition of a package | resim export-package-definition <package_address> <output> |
Show info about an entity | resim show <id> |
List all entities in simulator | resim show-ledger |
Reset simulator state | resim reset |
Note: The commands use the default account as transaction sender.
Follow this guide to build reproducible WASM and RDP files for your Scrypto blueprints.
The Dockerfile in the root of the repo should be work to build a docker image which will contain all the dependencies needed to be able build a blueprint using scrypto.
Build the docker image like. From the repo root
docker build -t radixdlt/simulator .
Then build your package by just running
docker run -v <path-to-your-scrypto-crate>:/src radixdlt/simulator
If you would like to avoid building the docker image, you can skip the build step and do the second step directly, docker will automatically download the docker image we publish
Build your blueprints directly with
docker run -v <path-to-your-scrypto-crate>:/src radixdlt/simulator
sbor
: The binary data format used by Scrypto.sbor-derive
: Derives for encoding and decoding Ruststruct
andenum
.scrypto
: Scrypto standard library.scrypto-schema
: Scrypto package schema.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.transaction
: Radix transaction manifest compiler, transaction models, signing and validationg logic.
Assets under assets-lfs
are stored in Git LFS.
To fetch files from LFS, install git-lfs
first:
- MacOS
brew install git-lfs
- Ubuntu
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash sudo apt-get install git-lfs
and then:
git lfs install
git lfs pull
To learn more about how to contribute to this project, read the Contributing Guide.