#public-key #key-string #byte-array #solana #macro #static #compile-time

macro static-pubkey

macro used for compile-time parsing of public key strings into byte arrays for near 0-cost static public keys

4 stable releases

1.0.3 Jun 10, 2022
1.0.2 Sep 29, 2021
1.0.1 Sep 28, 2021

#19 in #key-string

Download history 177/week @ 2023-11-27 219/week @ 2023-12-04 227/week @ 2023-12-11 296/week @ 2023-12-18 171/week @ 2023-12-25 191/week @ 2024-01-01 299/week @ 2024-01-08 352/week @ 2024-01-15 468/week @ 2024-01-22 209/week @ 2024-01-29 317/week @ 2024-02-05 417/week @ 2024-02-12 291/week @ 2024-02-19 280/week @ 2024-02-26 329/week @ 2024-03-04 128/week @ 2024-03-11

1,063 downloads per month
Used in 51 crates (25 directly)

MIT license

4KB

static-pubkey

docs.rs

The static-pubkey crate provides a macro static_pubkey!, used for compile-time parsing of strings into a static public key. This prvodies an efficient way of declaring public keys in source code while incurring almost no runtime cost in solana programs, without having to declare the byte array yourself. The actual code is taken from here.

usage

#[cfg(test)]
mod test {
    use static_pubkey::static_pubkey;
    #[test]
    fn example() {
        let key = static_pubkey!("GjphYQcbP1m3FuDyCTUJf2mUMxKPE3j6feWU1rxvC7Ps");
        assert!(key.to_string() == "GjphYQcbP1m3FuDyCTUJf2mUMxKPE3j6feWU1rxvC7Ps");
    }
}

links


lib.rs:

provides a macro used for compile-time parsing of public key strings into byte arrays for near 0-cost static public keys.

Dependencies

~1.5MB
~33K SLoC