pub struct Address {
    /// The underlying raw `b256` data of the address.
    bits: b256,
}
Expand description

The Address type, a struct wrapper around the inner b256 value.

Fields

bits: b256

The underlying raw b256 data of the address.

Implementations

pub fn bits(self) -> b256

Returns the underlying raw b256 data of the address.

Returns

  • [b256] - The raw data of the address.

Examples

fn foo() -> {
    let my_address = Address::zero();
    assert(my_address.bits() == b256::zero());
}

pub fn zero() -> Self

Returns the zero value for the Address type.

Returns

  • [Address] -> The zero value for the Address type.

Examples

fn foo() {
    let zero_address = Address::zero();
    assert(zero_address == Address:from(b256::zero()));
}

pub fn is_zero(self) -> bool

Returns whether an Address is set to zero.

Returns

  • [bool] -> True if the Address is zero, otherwise false.

Examples

fn foo() {
    let zero_address = Address::zero();
    assert(zero_address.is_zero());
}

Trait Implementations

pub fn abi_encode(self, buffer: Buffer) -> Buffer

pub fn abi_decode(refmut buffer: BufferReader) -> Self

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

pub 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);
}

pub fn from(bits: b256) -> Self

Casts raw b256 data to an Address.

Arguments

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

Returns

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

Examples

fn foo() {
   let address = Address::from(b256::zero());
}

pub fn try_from(bytes: Bytes) -> Option<Self>

Casts raw Bytes data to an Address.

Arguments

  • bytes: [Bytes] - The raw Bytes data to be casted.

Returns

  • [Address] - The newly created Address from the raw Bytes.

Examples

use std::bytes::Bytes;

fn foo(bytes: Bytes) {
   let result = Address::try_from(bytes);
   assert(result.is_some());
   let address = result.unwrap();
}

pub fn into(self) -> Bytes

Casts an Address to raw Bytes data.

Returns

  • [Bytes] - The underlying raw Bytes data of the Address.

Examples

fn foo() {
    let address = Address::zero();
    let bytes_data: Bytes = address.into()
    assert(bytes_data.len() == 32);
}

pub fn hash(
self,
refmut state: Hasher,
)