9 releases

0.2.4 Mar 19, 2025
0.2.3 Mar 18, 2025
0.2.2 Jan 3, 2025
0.2.1 Oct 26, 2024
0.0.0 Sep 25, 2024

#881 in Cryptography

Download history 98/week @ 2025-01-08 155/week @ 2025-01-15 65/week @ 2025-01-22 46/week @ 2025-01-29 102/week @ 2025-02-05 101/week @ 2025-02-12 128/week @ 2025-02-19 202/week @ 2025-02-26 181/week @ 2025-03-05 239/week @ 2025-03-12 597/week @ 2025-03-19 878/week @ 2025-03-26 535/week @ 2025-04-02 980/week @ 2025-04-09 941/week @ 2025-04-16 669/week @ 2025-04-23

3,304 downloads per month
Used in 12 crates (7 directly)

Apache-2.0

165KB
2K SLoC

pinocchio-pubkey

pinocchio-pubkey

Companion Pubkey helpers for pinocchio.

Overview

This crate provides two convenience macros to resolve Pubkeys at compile time:

  • pubkey!: takes a pubkey value as a base58 &str and generates its correspondent Pubkey (byte array)
  • declare_id!: takes a pubkey value as a base58 &str (usually representing a program address) and generates an ID constant, check_id() and id() helpers

It also defines a from_str helper that takes a &str and returns the correspondent Pubkey value.

Examples

Creating a Pubkey constant value from a static &str:

use pinocchio::pubkey::Pubkey;

pub const AUTHORITY: Pubkey = pinocchio_pubkey::pubkey!("7qtAvP4CJuSKauWHtHZJt9wmQRgvcFeUcU3xKrFzxKf1");

Declaring the program address of a program (usually on your lib.rs):

pinocchio_pubkey::declare_id!("Ping111111111111111111111111111111111111111");

Creating a Pubkey from a &str:

let address = String::from("7qtAvP4CJuSKauWHtHZJt9wmQRgvcFeUcU3xKrFzxKf1");
let owner = pinocchio_pubkey::from_str(&address);

License

The code is licensed under the Apache License Version 2.0

Dependencies