Skip to main content

runtime_token

Macro runtime_token 

Source
macro_rules! runtime_token {
    ($(#[$meta: meta])* $vis: vis $id: ident) => { ... };
    ($(#[$meta: meta])* $vis: vis $id: ident: $ty: ty) => { ... };
    ($($(#[$meta: meta])* $vis: vis $id: ident),*) => { ... };
    ($($(#[$meta: meta])* $vis: vis $id: ident: $ty: ty),*) => { ... };
}
Expand description

Produces tokens that are also checked at runtime, ensuring that a TokenCell is never accidentally used with another instance of the same token type.

Each token of a given type generated by [runtime_token] being identified by a u16 by default, constructing over 65536 instances may mean that distinct token instances share a same identifier, and may unlock each other’s cells.

This means that if you accidentally use the wrong instance of a runtime token on a cell, you are likely but not guaranteed to be protected by the identifier

You can chose the size of your tokens by calling runtime_token!(pub MyToken: uX). u64 has more overhead than the default u16, but guarantees that you will never accidentally use the wrong instance of a token undetected; therefore, runtime tokens that use u64 as their backing allow you to use the safe access methods to TokenCell