anchor_discriminant

Function anchor_discriminant 

Source
pub fn anchor_discriminant(input: &str) -> [u8; 8]
Expand description

Calculates the discriminant for a function using SHA-256 hash.

The discriminant is defined as the first 8 bytes of the SHA-256 hash of the function name.

NOTE: Functions require a namespace prefix, e.g. global:initialize. The default namespace is global.

§Arguments

  • input - A string slice that holds the function name.

§Returns

An array of 8 bytes representing the discriminant.

§Examples

let discriminant = sol_dev_utils::anchor_discriminant("global:initialize");
assert_eq!(discriminant, [175, 175, 109, 31, 13, 152, 155, 237]);