Macro selector_bytes

Source
selector_bytes!() { /* proc-macro */ }
Expand description

Computes the selector of the string and expands into its byte representation.

§Note

  • The computation takes place at compilation time of the crate.
  • Requires an ABI parameter as the first argument to specify the selector computation method.

§Arguments

  • Abi::Ink: Uses ink! ABI (BLAKE-2 256-bit hash)
  • Abi::Sol: Uses Solidity ABI (Keccak-256 hash)

§Example

// ink! ABI (BLAKE-2)
assert_eq!(selector_bytes!(Abi::Ink, "hello"), [50, 77, 207, 2],);

// Solidity ABI (Keccak-256)
assert_eq!(selector_bytes!(Abi::Sol, "hello"), [0x1c, 0x8a, 0xff, 0x95],);