Language for building DeFi apps on Radix.
Documentation: https://docs.radixdlt.com/docs/scrypto-1
-
Install Rust - we recommend to use Rust 1.77.2
- Install Rust (if Rust is installed you can skip this step)
- 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 llvm
Add LLVM to the system path by adding below line to the:~/.profile
ifbash
is the default shell~/.zshrc
ifzsh
is the default shell- respective config file in case of other shell
PATH="$(brew --prefix llvm)/bin:$PATH"
You can check, which shell is the default one by inspecting
$SHELL
variable:echo $SHELL
-
Install the Rust compiler:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
- Linux:
- Make sure a C++ compiler, LLVM, cmake and clang is installed:
sudo apt install build-essential llvm cmake clang
- Install the Rust compiler:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Set Rust version
rustup update rustup default 1.77.2
-
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 Radix CLIs
cargo install radix-clis
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> |
Show info about default account | resim show |
List all entities | resim show-ledger |
Reset ledger 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/radix-clis .
Then build your package by just running
docker run -v <path-to-your-scrypto-crate>:/src radixdlt/radix-clis
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/radix-clis
radix-blueprint-schema-init
: Blueprint schema initialization structures, used by Radix Package Definition (RPD).radix-clis
: Various CLI tools, likeresim
,scrypto
,rtmc
andrtmd
.radix-common-derive
: Macros for definingDecimal
andPreciseDecimal
.radix-common
: Common libraries used by Radix Engine and Scrypto.radix-engine
: The Radix Engine implementation.radix-native-sdk
: Library to assist native blueprint development.radix-sbor-derives
: Macros for encoding and decoding Scrypto SBOR and Manifest SBOR data.radix-substate-store-impls
: Various substate store implementations.radix-substate-store-interface
: The interface of any substate store.radix-substate-store-queries
: Interprets data in substate data by injecting high-level knowledge.radix-transaction-scenarios
: Defines various transaction scenarios, for testing.radix-transactions
: Radix transaction manifest compiler, transaction models, signing and validating logic.sbor-derive
: Macros for encoding and decoding SBOR data.sbor
: A generic binary data format, upon which Scrypto SBOR and Manifest SBOR are built.scrypto-derive
: Macros for defining blueprints.scrypto-test
: Library for testing Scrypto blueprints.scrypto
: Scrypto language abstraction.
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.
The executable components of the Scrypto Code including libraries, CLIs and docker images, are licensed under the Radix Software EULA.
The code in this repository is released under the Radix License 1.0 (modified Apache 2.0):
Copyright 2023 Radix Publishing Ltd incorporated in Jersey, Channel Islands.
Licensed under the Radix License, Version 1.0 (the "License"); you may not use
this file except in compliance with the License.
You may obtain a copy of the License at:
https://www.radixfoundation.org/licenses/license-v1
The Licensor hereby grants permission for the Canonical version of the Work to
be published, distributed and used under or by reference to the Licensor’s
trademark Radix® and use of any unregistered trade names, logos or get-up.
The Licensor provides the Work (and each Contributor provides its Contributions)
on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
PURPOSE.
Whilst the Work is capable of being deployed, used and adopted (instantiated) to
create a distributed ledger it is your responsibility to test and validate the
code, together with all logic and performance of that code under all foreseeable
scenarios.
The Licensor does not make or purport to make and hereby excludes liability for
all and any representation, warranty or undertaking in any form whatsoever,
whether express or implied, to any entity or person, including any
representation, warranty or undertaking, as to the functionality security use,
value or other characteristics of any distributed ledger nor in respect the
functioning or value of any tokens which may be created stored or transferred
using the Work.
The Licensor does not warrant that the Work or any use of the Work complies with
any law or regulation in any territory where it may be implemented or used or
that it will be appropriate for any specific purpose.
Neither the licensor nor any current or former employees, officers, directors,
partners, trustees, representatives, agents, advisors, contractors, or
volunteers of the Licensor shall be liable for any direct or indirect, special,
incidental, consequential or other losses of any kind, in tort, contract or
otherwise (including but not limited to loss of revenue, income or profits, or
loss of use or data, or loss of reputation, or loss of any economic or other
opportunity of whatsoever nature or howsoever arising), arising out of or in
connection with (without limitation of any use, misuse, of any ledger system or
use made or its functionality or any performance or operation of any code or
protocol caused by bugs or programming or logic errors or otherwise);
A. any offer, purchase, holding, use, sale, exchange or transmission of any
cryptographic keys, tokens or assets created, exchanged, stored or arising from
any interaction with the Work;
B. any failure in a transmission or loss of any token or assets keys or other
digital artifacts due to errors in transmission;
C. bugs, hacks, logic errors or faults in the Work or any communication;
D. system software or apparatus including but not limited to losses caused by
errors in holding or transmitting tokens by any third-party;
E. breaches or failure of security including hacker attacks, loss or disclosure
of password, loss of private key, unauthorised use or misuse of such passwords
or keys;
F. any losses including loss of anticipated savings or other benefits resulting
from use of the Work or any changes to the Work (however implemented).
You are solely responsible for; testing, validating and evaluation of all
operation logic, functionality, security and appropriateness of using the Work
for any commercial or non-commercial purpose and for any reproduction or
redistribution by You of the Work. You assume all risks associated with Your use
of the Work and the exercise of permissions under this Licence.
The code 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.