https://github.com/sol-farm/static-pubkey
a macro used for compile-time parsing of public key strings into byte arrays for near 0-cost static public keys
https://github.com/sol-farm/static-pubkey
Last synced: 3 days ago
JSON representation
a macro used for compile-time parsing of public key strings into byte arrays for near 0-cost static public keys
- Host: GitHub
- URL: https://github.com/sol-farm/static-pubkey
- Owner: sol-farm
- License: mit
- Created: 2021-09-28T08:29:30.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-10T20:49:31.000Z (about 3 years ago)
- Last Synced: 2025-06-05T05:02:43.944Z (about 1 month ago)
- Language: Rust
- Homepage:
- Size: 24.4 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# static-pubkey

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](https://github.com/project-serum/anchor/commit/96036e149173603926074c6dba445c47bd6575aa).
# usage
```rust
#[cfg(test)]
mod test {
use static_pubkey::static_pubkey;
#[test]
fn example() {
let key = static_pubkey!("GjphYQcbP1m3FuDyCTUJf2mUMxKPE3j6feWU1rxvC7Ps");
assert!(key.to_string() == "GjphYQcbP1m3FuDyCTUJf2mUMxKPE3j6feWU1rxvC7Ps");
}
}
```# links
* [crates.io](https://crates.io/crates/static-pubkey)
* [docs.rs](https://docs.rs/crate/static-pubkey)