npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@layerzerolabs/program-id-solana-contracts

v1.2.94

Published

Readme

@layerzerolabs/program-id-solana-contracts

A cargo-tracked replacement for solana_helper::program_id_from_env!, for Solana programs whose address is supplied at build time.

Usage

use anchor_lang::prelude::*;
use program_id::declare_program_id;

declare_program_id!("OFT_ID", "9UovNrJD8pQyBLheeHNayuG1wJSEAoxkmM14vw5gcsTT");

Takes the program ID from $OFT_ID, falling back to the literal. Expand it in a crate that has anchor_lang::prelude::* in scope.

Problem

program_id_from_env! is a proc macro that calls std::env::var while it expands. Cargo's fingerprint cannot observe that read, so a rebuild with a different value recompiles nothing and re-emits the program ID from the previous build. Nothing fails loudly — the .so carries the wrong address.

That artifact cannot be repaired after the fact. A program ID is folded into .text as BPF lddw immediates at ~150 sites, and Anchor const-evaluates the __event_authority bump from it, so changing it is a compilation process, not a patch.

How it works

declare_program_id! expands the declare_id! alongside an option_env!($var) marker. rustc records that marker as an environment dependency of the calling crate, so cargo rebuilds whenever the variable changes.

The crate does not depend on anchor-lang, so it cannot force an anchor version on a consumer.

Adopting it

  • Repair the IDL. anchor idl build recovers the address by text-matching declare_id!, so any non-literal form yields a garbage address field. Chain add_address_to_idl.py --idl-dir <dir> (present in the anchor image) after it, which re-derives the address via cargo expand.
  • Pass the variable to every step. The compile and the IDL build are separate lz-tool invocations; both need the same value or the .so and the IDL disagree.
  • Pass it with lz-tool --env, not cargo's [env] table. [env] does not override a variable already set in the process environment, and --config cannot express force = true.
  • Expect a new .so. The marker adds no bytes to the artifact, but replacing a literal declare_id! shifts source lines, which moves panic::Location constants.

Tests

  • pnpm test:rebuild — builds tests/probe twice with different IDs without cleaning, and fails if the second build does not follow. Deleting the option_env! marker makes it fail.
  • pnpm test:idl-shape — expands the probe and asserts add_address_to_idl.py's matcher recovers the probe's declared ID.
  • pnpm test:unit — default fallback and base58 decoding.