Page cover

Deterministic Address Derivation (PDAs)

Solana’s Program Derived Addresses (PDAs) are central to how Nyvo creates predictable accounts for your dApp. A PDA is a special address derived from a program ID and one or more seed values, such that no private key exists for it (it lies off the Ed25519 curve). PDAs enable deterministic accounts – given the same seeds and program, the address will always be the same. Nyvo uses this for organizing state. For example, if you have a marketplace, Nyvo might derive a PDA for each item listing using seeds like (listing_id, seller_pubkey, program_id). This way, anyone (including the front-end or another integration) can independently compute where a given listing’s account should be, without needing it stored in a registry.

In Nyvo’s modules, common PDA usage includes:

  • Authority PDAs: If a program needs to perform token transfers, it often uses a PDA as its authority. Nyvo’s staking pool might have a PDA that owns the token vault, allowing the program to move staked tokens on behalf of users. Because the program can sign for that PDA, it provides security (users cannot steal from the vault, but the program can transfer for reward payouts).

  • Mapping Structures: Nyvo uses PDAs to create on-chain maps. For example, in a governance module, Proposal42 might be stored at PDA = hash("proposal", 42, program_id). This functions like a key-value store: given a proposal id, derive the address. The Solana runtime function findProgramAddress (exposed in SDKs as well) is used for this and returns both the PDA and a bump (the bump is a little number so that if the first hash happens to land on a curve point (i.e., a valid key), it increments a byte until an off-curve address is found).

  • Multi-Tenancy: It’s possible to have one program instance serve multiple “projects” by using PDAs to segregate data. For instance, a launchpad program could have a PDA per launch event (using event name or ID as seed). In practice, Nyvo usually deploys a fresh program per project, but understanding PDAs helps if you consider more complex uses or debugging address calculations.

From a developer standpoint, when you use Nyvo’s API to fetch data, you might see functions like NyvoApi.staking.getUserStakeAccount(walletPubkey). Under the hood, this likely performs a PDA derivation of the user’s stake account (with seeds like user pubkey and pool pubkey). Knowing this, if you ever need to manually inspect or query accounts (outside of Nyvo’s provided UI), you can reproduce the PDA logic using Solana CLI or web3 code to ensure you target the correct addresses.

Last updated