Migrating from Scrypto v0.12.0 to v1.0

Latest compatible product versions

By using the binaries, including libraries, CLIs and docker images you agree to the End User License Agreement. You can find all terms and conditions here.

Engine, Node and Scrypto:

App Building Tools:

Public Applications:

Changes from v0.12 to v1.0

This section captures changes between v0.12 and v1.0.

At the time this doc is published, the "stokenet" network will be running babylon (compatible with Scrypto 1.0).

Another Decimal Update

The dec! and pdec! macros have been overhauled to improve their efficiency. The parsing of decimal strings is now completely compile-time, which means the parsing logic won’t be built into your blueprint WASM files. This reduces code size and transaction runtime costs.

In addition to existing support of integer and string literal. The updated macros now support float literal as well, such as dec!(123.45678).

Also, a few new decimal constants have been added to Decimal and PreciseDecimal, such as ONE_TENTH.

Registered Types for KeyValueStore and NF resources

When creating NF resources and key value stores, you can now specify a type that is registered to a blueprint, instead of passing the whole type schema to the system. This greatly reduces code size and transaction runtime costs.

Creating KeyValueStore with Registered Type

use scrypto::prelude::*;

#[blueprint]
#[types(Hash, Epoch)] // First, register the key type and value type here
mod example {
    struct Example {
        kv_store: KeyValueStore<Hash, Epoch>,
    }

    impl Example {
        pub fn new() -> Global<Example> {
            Self {
                // Then, use `new_with_registered_type` instead of `new` for creating a key value store
                kv_store: KeyValueStore::new_with_registered_type(),
            }
            .instantiate()
            .prepare_to_globalize(OwnerRole::None)
            .globalize()
        }
    }
}

Note that the #[types(…​)] macro only accepts a path to a type, so it must be defined upfront somewhere else. As a result, to register type (PackageAddress, String), you will need to use:

pub type MyAwesomeType = (PackageAddress, String);
#[types(MyAwesomeType)]

Creating NF Resource with Registered Type

use scrypto::prelude::*;

#[derive(ScryptoSbor, NonFungibleData)]
pub struct TestData {
    pub amount_due: Decimal,
}

#[blueprint]
#[types(TestData)] // First, register the non-fungible data type here
mod example {
    struct Example {}

    impl Example {
        pub fn create_non_fungible_resource() {
            // Then, use the `_with_registered_type` interface
            ResourceBuilder::new_ruid_non_fungible_with_registered_type::<TestData>(OwnerRole::None)
                .create_with_no_initial_supply();
        }
    }
}

If you intend to use a type that is registered under another blueprint, try the following:

// Replace `FlashLoan` with your blueprint and `LenderOrder` with the registered type
<ResourceBuilder as FlashLoanResourceBuilder>::new_integer_non_fungible_with_registered_type::<LendOrder>(OwnerRole::None)
    .create_with_no_initial_supply();

Scrypto Builder Docker Image

With 1.0, you can now use a Docker image to build your Scrypto Blueprint. This produces WASM files deterministically, so others may verify that your published package’s source code does correspond to what they see on ledger.

First, install Docker if you haven’t done so. The official installation guide is here.

Then, pull the official Docker image for v1.0.0

DOCKER_DEFAULT_PLATFORM=linux/amd64 docker pull radixdlt/scrypto-builder:v1.0.0

After that, run

DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run -v <path-to-your-scrypto-crate>:/src radixdlt/scrypto-builder:v1.0.0

RESIM Updates

Two enhancements have been added to RESIM CLIs:

resim call-function/method now supports GlobalAddress arguments. If a Scrypto function or method takes a GlobalAddress, you can pass a bech32 global address.

A new argument --log-level has been added to scrypto build. The supported log levels are ERROR, WARN, INFO, DEBUG, TRACE. Scrypto builder will strip the logging code if its severity is lower than specified. This reduces the WASM code size. By default, --log-level is set to INFO.

Integer Type Tweaks

A few methods have been removed from integer types, i.e. Ixxx` and Uxxx, due to low usage:

  • Removed rotate methods

  • Removed to_vec method

  • Removed By trait and its implementation

Slight Costing Adjustments

The fee table has received minor adjustments to reflect optimizations and tightened security checks introduced to Radix Engine.

If you have been using events a lot, you will see an increase in transaction fees. This is due to a bugfix to how event storage cost is billed.

Other Minor Changes

Based on community feedback, the following methods have been restored:

  • TestRunner::component_state - reading component states using test runner

  • Global::<T>::blueprint_id() - querying the blueprint ID of a global component

In addition, TimePrecision has been added to Scrypto prelude.

Finally, the MAX_NUMBER_OF_FUNCTION_LOCALS limit has been increased from 128 to 256. If you were unable to build your project to hitting function locals limit, you may be able to do it now.