pub struct AssetId {
    bits: b256,
}
Expand description

An AssetId is used for interacting with an asset on the network.

Additional Information

It is calculated by taking the sha256 hash of the originating ContractId and a SubId.
i.e. sha256((contract_id, sub_id)).

An exception is the Base Asset.

The SubId is used to differentiate between different assets that are created by the same contract.

Fields

bits: b256

Trait Implementations

fn hash(
self,
refmut state: Hasher,
)

fn eq(self, other: Self) -> bool

fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

Additional Information

This function is inherited when eq() is implemented.

Arguments

  • other: [Self] - The value of the same type.

Returns

  • [bool] - true if the two values are not equal, otherwise false.

Examples

struct MyStruct {
    val: u64,
}

impl Eq for MyStruct {
    fn eq(self, other: Self) -> bool {
         self.val == other.val
    }
}

fn foo() {
    let struct1 = MyStruct { val: 10 };
    let struct2 = MyStruct { val: 2 };
    let result = struct1 != struct2;
    assert(result);
}

fn from(bits: b256) -> Self

Casts raw b256 data to an AssetId.

Arguments

  • bits: [b256] - The raw b256 data to be casted.

Returns

  • [AssetId] - The newly created AssetId from the raw b256.

Examples

use std::constants::ZERO_B256;

fn foo() {
   let asset_id = AssetId::from(ZERO_B256);
}