#solana #public-key

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

#178 in #public-key

Download history 336/week @ 2025-07-07 258/week @ 2025-07-14 216/week @ 2025-07-21 189/week @ 2025-07-28 170/week @ 2025-08-04 217/week @ 2025-08-11 181/week @ 2025-08-18 322/week @ 2025-08-25 353/week @ 2025-09-01 311/week @ 2025-09-08 325/week @ 2025-09-15 325/week @ 2025-09-22 449/week @ 2025-09-29 256/week @ 2025-10-06 314/week @ 2025-10-13 322/week @ 2025-10-20

1,397 downloads per month
Used in 47 crates (25 directly)

MIT license

4KB

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


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

Dependencies

~1.5MB
~40K SLoC