Expand description
Scrypto preludes.
Re-exports§
pub use crate::engine::scrypto_env::ScryptoVmV1Api;
pub use radix_engine_interface::radix_engine_common;
pub use crate::component::*;
pub use crate::crypto_utils::*;
pub use crate::engine::*;
pub use crate::modules::*;
pub use crate::resource::*;
pub use crate::runtime::*;
Modules§
- Documentation for Additional Attributes
- Definitions of safe integers and uints.
- A contiguous growable array type with heap-allocated contents, written
Vec<T>
.
Macros§
- Creates a
Decimal
from literals. It is a compile-time macro. It allows to declare constants and statics. Example: const D1: Decimal = dec!(“1111.11111”) const D2: Decimal = dec!(“-1111.11111”) const D3: Decimal = dec!(1) const D4: Decimal = dec!(-1_0000_000_u128) - This macro is intended for creating a data model which supports versioning. This is useful for creating an SBOR data model which can be updated in future. In future, enum variants can be added, and automatically mapped to.
- This macro is intended for creating a data model which supports versioning. This is useful for creating an SBOR data model which can be updated in future. In future, enum variants can be added, and automatically mapped to.
- Creates a
String
using interpolation of runtime expressions. - Creates a safe integer from literals. You must specify the type of the integer you want to create.
- Includes the WASM file of a Scrypto package.
- Includes the schema file of a Scrypto package.
- Creates a
PreciseDecimal
from literals. It is a compile-time macro. It allows to declare constants and statics. Example: const D1: PreciseDecimal = pdec!(“1111.11111”) const D2: PreciseDecimal = pdec!(“-1111.11111”) const D3: PreciseDecimal = pdec!(1) const D4: PreciseDecimal = pdec!(-1_0000_000_u128) - Roles macro for main module
- Creates a
Vec
containing the arguments.
Structs§
- Represents a decoder which understands how to decode Scrypto addresses in Bech32.
- Represents an encoder which understands how to encode Scrypto addresses in Bech32.
- An iterator over the variants of Self
- An ordered map based on a B-Tree.
- An ordered set based on a B-Tree.
- Represents a BLS12-381 G1 public key.
- Represents a BLS12-381 G2 signature (variant with 96-byte signature and 48-byte public key)
- Core object state, persisted in
TypeInfoSubstate
. - An error returned by
RefCell::try_borrow
. - An error returned by
RefCell::try_borrow_mut
. - A pointer type that uniquely owns a heap allocation of type
T
. - Bytes, of length between 1 and 64.
- A mutable memory location.
- Address to a global component
- Royalty rules
Decimal
represents a 192 bit representation of a fixed-scale decimal number.- Represents an ED25519 public key.
- Represents an ED25519 signature.
- A type-safe consensus epoch number.
- Identifies a specific event schema emitter by some emitter RENode.
- An identifier for a type under a given node’s schema context in the Radix network.
- Address to a global entity
- Represents a 32-byte hash digest.
- Represents a 32-byte hash accumulator.
- Represents an HRP set (typically corresponds to a network).
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Represents a Unix timestamp, capturing the seconds since the unix epoch.
- Unsigned integers, up to u64.
- Address to a local entity
- Represents additional validation that should be performed on the size.
- A doubly-linked list with owned nodes.
- Represents the global id of a non-fungible.
- For typed value, to skip any codec
- For manifest
- For typed value, to skip any codec
- For manifest
- For typed value, to skip any codec
- For manifest
- For typed value, to skip any codec
- For manifest
- For typed value, to skip any codec
- For typed value, to skip any codec
- For manifest
- This is the struct used in the Schema
- Represents additional validation that should be performed on the numeric value.
- A cell which can be written to only once.
- Zero-sized type used to mark things that “act like” they own a
T
. PreciseDecimal
represents a 256 bit representation of a fixed-scale decimal number.- A wrapper for a full encoded SBOR payload, including the prefix byte.
- A wrapper for a reference to a valid partial SBOR payload representing a single value.
- A single-threaded reference-counting pointer. ‘Rc’ stands for ‘Reference Counted’.
- Wraps a borrowed reference to a value in a
RefCell
box. A wrapper type for an immutably borrowed value from aRefCell<T>
. - A mutable memory location with dynamically checked borrow rules
- A wrapper type for a mutably borrowed value from a
RefCell<T>
. - A series of indexes which describes some value in the sbor tree
- A wrapper for a full encoded SBOR payload, including the prefix byte.
- A wrapper for a reference to a valid partial SBOR payload representing a single value.
- An array of custom type kinds, and associated extra information which can attach to the type kinds
- Represents an ECDSA Secp256k1 public key.
- Represents an ECDSA Secp256k1 signature.
- A UTF-8–encoded, growable string.
- Combines all data about a Type:
- This enables the type to be represented as eg JSON Also used to facilitate type reconstruction
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- Provides safe integer arithmetic.
- The core primitive for interior mutability in Rust.
- A contiguous growable array type, written as
Vec<T>
, short for ‘vector’. - A
Decoder
abstracts the logic for decoding basic types. - A double-ended queue implemented with a growable ring buffer.
- LazyCellExperimentalA value which is initialized on the first access.
- Note - this is quite similar to ManifestDecompilationDisplayContext
- An iterator over the variants of Self
- Network Definition is intended to be the actual definition of a network
- The unique identifier of a (stored) node.
- A thin wrapper around a
HashMap
, which guarantees that aHashMap
usage will not result in a non-deterministic execution (simply by disallowing the iteration over its elements). - Address to a global package
- The unique identifier of a node module.
- RUID, v4, variant 1, big endian. See https://www.rfc-editor.org/rfc/rfc4122
- Address to a global resource
- A type-safe consensus round number within a single epoch.
- Represents a particular schema under a package
- An identifier for a type in the context of a schema.
- A string matching
[_0-9a-zA-Z]{1,64}
. - SyncUnsafeCellExperimental
UnsafeCell
, butSync
. - A
UtcDateTime
represents a Unix timestamp on the UTC Calendar. - An
Encoder
abstracts the logic for writing core types into a byte buffer.
Enums§
- A clone-on-write smart pointer.
- Represents an error occurred during decoding.
- Represents an error occurred during encoding.
- An enum which represents the different addressable entities.
- A reference to the type to substitute with for the case of generics.
- Less flexible than previous revision, as mixed type origin is not allowed, but better for client-side optimization
- Represents the level of a log message.
- The TypeId which is local to a given
Schema
. This is theSchemaTypeLink
used in a linearizedSchema
to linkTypeKind
s. - Any address supported by manifest, both global and local.
- Represents type of non-fungible id
- Represents the local id of a non-fungible.
- The
Option
type. See the module level documentation for more. - Front end data structure for specifying owner role
- Royalty rules
- Royalty rules
- Represents an error when retrieving BLS public key from hex or when aggregating.
- Represents an error when retrieving BLS signature from hex or when aggregating.
- Represents an error when parsing Decimal from another type.
- Represents an error when parsing ED25519 public key from hex.
- The
ParseError
enum is a collection of all the possible reasons an enum can fail to parse from a string. - Represents an error when parsing hash.
- Represents an error when parsing ManifestAddressReservation.
- Represents an error when parsing ManifestBlobRef.
- Represents an error when parsing ManifestBucket.
- Represents an error when parsing ManifestDecimal.
- Represents an error when parsing ManifestExpression.
- Represents an error when parsing ManifestPreciseDecimal.
- Represents an error when parsing ManifestProof.
- Represents an error when parsing non-fungible address.
- Represents an error when decoding non-fungible id.
- Represents an error when parsing PreciseDecimal from another type.
- Represents an error when parsing ED25519 public key from hex.
- Resource Proof Rules
- Represents any natively supported public key.
- The hash of a given public key.
- Represents the type of a resource.
- Defines the rounding strategy.
- This is a compile-time identifier for a given type, used by the type aggregator to uniquely identify a type.
- Represents any value conforming to the SBOR value model.
- A schema for the values that a codec can decode / views as valid
- The unique identifier of a substate within a node module.
- A schema for the values that a codec can decode / views as valid
- Additional validation to apply to a payload of the given type, beyond validation from the
TypeKind
’s type structure. - Represents any value conforming to the SBOR value model.
- Define the withdraw strategy when request amount does not match underlying resource divisibility.
Constants§
- The native package for access controllers.
- The non-fungible badge resource which is used for account ownership, if accounts have been set up with simple account creation, or have been securified.
- The native package for accounts.
- The price for adding a single byte to archive storage, in XRD. 1 MB = 6 USD This is primarily for transaction payload, events and logs.
- BLS12-381 ciphersuite v1 It has following parameters
- Depth limit for various types of blueprint payload
- Used only with TRANSACTION_TRACKER Node for boot loading
- The consensus manager native component - in charge of validators, consensus and epochs.
- The native package for the consensus manager.
- A custom type is an application defined type with special semantics.
- The default tip percentage to use when building a transaction.
- The non-fungible badge resource which is used for virtual proofs of EdDSA Ed25519 transacton signatures in the transaction processor.
- The execution cost unit limit.
- The execution cost units loaned from system
- The price of execution cost unit, in XRD.
- The faucet native component - use this on testnets for getting XRD and locking fee.
- The name of the faucet blueprint under the
FAUCET_PACKAGE
. - The faucet native component - use this on testnets for getting XRD and locking fee.
- The scrypto package for the faucet
- The finalization cost unit limit.
- The price of finalization cost unit, in XRD.
- The genesis helper scrypto component - used for sorting out genesis.
- The name of the genesis helper blueprint under the
GENESIS_HELPER_PACKAGE
. - The scrypto package for the genesis helper.
- The non-fungible badge resource which is used for virtual proofs which represent the global ancestor of the actor which made the latest global call.
- The non-fungible badge resource which is used for identity ownership, if identities have been set up with simple account creation, or have been securified.
- The native package for identities.
- Depth limit for the key and value of an entry in
KeyValueStore
- 0x4d = M in ASCII for Manifest - (77 in decimal)
- The max depth of an access rule, to protect unbounded native stack usage
- The max number of access rule nodes in an access rule
- The max length of a blueprint identifier
- The max call depth, used by transaction executor.
- The max epoch range Should be ~ 1 month. The below is ~30 days given 5 minute epochs.
- The max length of an event name
- The max event size
- The max length of a feature name
- The max length of a function name
- The max total heap substate size.
- The maximum initial table size
- The maximum invoke payload size.
- The max log size
- The maximum memory size (per call frame): 64 * 64KiB = 4MiB
- The max SBOR size of metadata key
- The max SBOR size of metadata value
- The max number of fields a blueprint can have
- The max number of labels of a table jump, excluding the default
- The maximum number of “live” buffers maintained by Scrypto runtime.
- The max number of events
- The max number of functions
- The max number of function local variables
- The max number of function parameters
- The max number of global variables
- The max number of logs
- The max length of an Origin in metadata
- The max panic message size
- The maximum that a package or component owner is allowed to set their method royalty to. 10 USD
- The max number of roles in a Role Specification
- The max length of a role name
- The maximum substate key read and write size
- The maximum substate read and write size.
- The maximum value of tip percentage
- The max total track substate size.
- The max transaction size
- The max length of a registered type name
- The max length of a URL in metadata
- The native package for the metadata module.
- The minimum value of tip percentage
- The proposer’s share of network fees (execution, finalization and storage)
- The validator set’s share of network fees (execution, finalization and storage)
- The non-fungible badge resource which is used for virtual proofs which represent the package of the immediate caller - ie the actor which made the latest (global or internal) call.
- The non-fungible badge resource which is used for package ownership when creating packages with the simple package creation set-up.
- The native package for package deployment.
- The native package for pools.
- The free credit amount used by preview. 1000000 XRD = $60000, which should be enough to cover all sensible preview requests.
- The native package for resource managers, proofs, buckets, vaults etc.
- The ROLA hash which is signed is created as
hash(ROLA_HASHABLE_PAYLOAD_PREFIX || ..)
- The native package for the role assignment module.
- The native package for the royalty module.
- 0x5c for [5c]rypto - (92 in decimal)
- The non-fungible badge resource which is used for virtual proofs of ECDSA Secp256k1 transacton signatures in the transaction processor.
- The price for adding a single byte to state storage, in XRD. 1 MB = 6 USD
- The non-fungible badge resource which is used for virtual proofs representing the fact that the current transaction is a system transaction.
- The native package for test utils.
- The proposer’s share of tips
- The validator set’s share of tips
- The Transaction hash which is signed is created as:
hash(TRANSACTION_HASHABLE_PAYLOAD_PREFIX || version prefix according to type of transaction payload || ..)
- The native package for the transaction processor.
- The intent hash store component
- Depth limit for the default value of a transient substate
- The USD price, in XRD. 1 XRD = 0.06 USD
- The non-fungible badge resource which is used for validator ownership.
- The number of entries in the engine cache
- XRD is the native token of the Radix ledger. It is a fungible token, measured in attos (
10^-18
).
Statics§
Traits§
- Used to do a cheap mutable-to-mutable reference conversion.
- Used to do a cheap reference-to-reference conversion.
- AsStaticRefDeprecatedA cheap reference-to-reference conversion. Used to convert a value to a reference value with
'static
lifetime within generic code. - The
Categorize
trait marks a rust type as having a fixed value kind for SBOR encoding/decoding. - Api which exposes methods in the context of the actor
- Api to manage an iterable index
- Interface of the system, for blueprints and Node modules.
- A high level api to read/write fields
- A high level interface to manipulate objects in the actor’s call frame
- A common trait for the ability to explicitly duplicate an object.
- This trait is used where context is required to correctly display a value.
- This trait is used where context is required to correctly serialize a value.
- Types whose values can be duplicated simply by copying bits.
- Represents a custom SBOR value.
?
formatting.- A data structure that can be decoded from a byte array using SBOR.
- A trait for giving a type a useful default value.
- The
Describe
trait allows a type to describe how to interpret and validate a corresponding SBOR payload. - Format trait for an empty format,
{}
. - An iterator able to yield elements from both ends.
- Custom code within the destructor.
- A data structure that can be serialized into a byte array using SBOR.
- A trait for capturing the number of variants in Enum. This trait can be autoderived by
strum_macros
. - Associates additional pieces of information with an Enum. This can be autoimplemented by deriving
EnumMessage
and annotating your variants with#[strum(message="...")]
. EnumProperty
is a trait that makes it possible to store additional information with enum variants. This trait is designed to be used with the macro of the same name in thestrum_macros
crate. Currently, the only string literals are supported in attributes, the other methods will be implemented as additional attribute types become stabilized.- Trait for comparisons corresponding to equivalence relations.
- An iterator that knows its exact length.
- Extend a collection with the contents of an iterator.
- The version of the call operator that takes an immutable receiver.
- The version of the call operator that takes a mutable receiver.
- The version of the call operator that takes a by-value receiver.
- Used to do value-to-value conversions while consuming the input value. It is the reciprocal of
Into
. - Conversion from an
Iterator
. - A generic trait for converting a number to a value.
- Parse a value from a string
- A marker trait to indicate that the type is versioned. This can be used for type bounds for requiring that types are versioned.
- A value-to-value conversion that consumes the input value. The opposite of
From
. - This trait designates that an
Enum
can be iterated over. It can be auto generated usingstrum_macros
on your behalf. - Conversion into an
Iterator
. - Marks the rust type that represents a non-fungible id, of non-auto-generated kind (i.e. String, Integer and Bytes).
- Marks the rust type that represents a non-fungible id, of any kind (i.e. String, Integer, Bytes and RUID).
- A trait for dealing with iterators.
- Represents the data structure of a non-fungible.
- Defines a multiplicative identity element for
Self
. - Trait for types that form a total order.
- Trait for comparisons using the equality operator.
- Trait for types that form a partial order.
- Binary operator for raising a value to a power.
- Represents a custom SBOR value.
- Marker trait for encoding as an Sbor Enum
- Marker trait for encoding as an Sbor Tuple
- Marker trait for a link between
TypeKind
s: - Types that can be transferred across thread boundaries.
- Useful functions for signed numbers (i.e. numbers that can be negative).
- Types with a constant size known at compile time.
- Types for which it is safe to share references between threads.
- A generalization of
Clone
to borrowed data. - A generic trait for converting a value to a number.
- A trait for converting a value to a
String
. - Simple and safe type conversions that may fail in a controlled way under some circumstances. It is the reciprocal of
TryInto
. - An attempted conversion that consumes
self
, which may or may not be expensive. - Types that do not require any pinning guarantees.
- A trait for retrieving the names of each variant in Enum. This trait can be autoderived by
strum_macros
. - Defines an additive identity element for
Self
.
Functions§
- Performs BLS12-381 G2 aggregated signature verification of multiple messages each signed with different key. Domain specifier tag: BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_
- Decode an instance of
T
from a slice. - Encode a
T
into byte array. - Creates a payload traverser from the buffer
- NOTE: The below code is copied with minor alterations from the bech32 crate. These alterations are to avoid using std for allocations, and fit with the sbor no-alloc options.
- Combines a u8 with a u8 slice.
- Copies a slice to a fixed-sized array.
- Disposes of a value.
- Performs BLS12-381 G2 aggregated signature verification one message signed with multiple keys. Domain specifier tag: BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_
- A requirement for the global ancestor of the actor who made the latest global call to either be:
- Computes the hash digest of a message.
- Creates an empty map with capacity 0 and default Hasher
- Creates an empty map with given capacity and default Hasher
- Creates an empty set with capacity 0 and default Hasher
- Creates an empty set with given capacity and default Hasher
- This is safe for std and no-std use cases (unlike
IndexMap::new
which disappears when std is not in the toolchain - see this article for deep technical reasons) - This is safe for std and no-std use cases (unlike
IndexMap::with_capacity
which disappears when std is not in the toolchain - see this article for deep technical reasons) - This is safe for std and no-std use cases (unlike
IndexSet::new
which disappears when std is not in the toolchain - see this article for deep technical reasons) - This is safe for std and no-std use cases (unlike
IndexSet::with_capacity
which disappears when std is not in the toolchain - see this article for deep technical reasons) - A requirement for the immediate caller’s package to equal the given package.
- Decodes a data structure from a byte array.
- Encodes a data structure into byte array.
- ============================================== (DEPRECATED) TRAVERSAL
- Performs BLS12-381 G2 signature verification. Domain specifier tag: BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_
Type Aliases§
- Notes: This is to be deprecated, please use
ModuleId
instead - We should always
UncheckedOrigin
in Scrypto, as the validation logic is heavy. Thus, this type alias is added. - We should always
UncheckedUrl
in Scrypto, as the validation logic is heavy. Thus, this type alias is added. - An index of a specific validator within the current validator set. To be exact: a
ValidatorIndex
equal tok
references thek-th
element returned by the iterator of theIndexMap<ComponentAddress, Validator>
in this epoch’s active validator set (which is expected to be sorted by stake, descending). This uniquely identifies the validator, while being shorter thanComponentAddress
(we do care about the constant factor of the space taken byLeaderProposalHistory
under prolonged liveness break scenarios).
Attribute Macros§
- Declares a blueprint.
Derive Macros§
- Converts enum variants to
&'static str
. - Derive code that returns the value kind - specifically for Basic SBOR.
- Derive code that decodes this data structure from a byte array - specifically for Basic SBOR.
- Derive code that describes the type - specifically for Basic SBOR.
- Derive code that encodes this data structure - specifically for Basic SBOR.
- Derive code that returns the value kind.
- Derive macro generating an impl of the trait
Clone
. - Derive macro generating an impl of the trait
Copy
. - Derive macro generating an impl of the trait
Debug
. - Derive code that decodes this data structure from a byte array.
- Derive macro generating an impl of the trait
Default
. - Derive code that describes this type.
- Converts enum variants to strings.
- Derive code that encodes this data structure
- Add a constant
usize
equal to the number of variants. - Generate a new type with only the discriminant names.
- Creates a new type that iterates of the variants of an enum.
- Add a verbose message to an enum variant.
- Add custom properties to enum variants.
- Converts strings to enum variants based on their name.
- Implements
Strum::VariantNames
which adds an associated constantVARIANTS
which is an array of discriminant names. - Derive macro generating an impl of the trait
Eq
. - Add a function to enum that allows accessing variants by its discriminant
- Implements
From<MyEnum> for &'static str
on an enum. - Derives code for categorizing a struct or enum with Manifest value model.
- Derives code for decoding a struct or enum with Manifest value model.
- Derives code for encoding a struct or enum with Manifest value model.
- Derive code that describe a non-fungible data structure.
- Derive macro generating an impl of the trait
PartialOrd
. The behavior of this macro is described in detail here. - Derives code for categorizing a struct or enum with Scrypto value model.
- Derives code for decoding a struct or enum with Scrypto value model.
- Derives code for encoding a struct or enum with Scrypto value model.
- Derive code for implementing the required logic to mark a type as being an event.
- implements
std::string::ToString
on en enum