Skip to Content

Get PDA and Bump

Calculates a Program Derived Address (PDA) and its bump seed from a program address and seeds. Automatically handles encoding of different seed types (strings, addresses, and bigints).

Returns: Promise<{pda: Address, bump: number}>

const { pda, bump } = await connection.getPDAAndBump( programAddress, ["my-seed", walletAddress, 123n] );

Parameters

  • programAddress: Address - The program address to derive the PDA from
  • seeds: Array<String | Address | BigInt> - Array of seeds to derive the PDA. Can be a mix of:
    • string - Will be encoded as UTF-8 bytes
    • Address - Will be encoded as a Solana address
    • BigInt - Will be encoded as little-endian bytes

Examples

Create a PDA with string seeds:

const { pda, bump } = await connection.getPDAAndBump( programAddress, ["my-seed", "another-seed"] );

Create a PDA with mixed seed types:

const { pda, bump } = await connection.getPDAAndBump( programAddress, ["my-seed", walletAddress, 123n] );

Create a PDA with just a number seed:

const { pda, bump } = await connection.getPDAAndBump( programAddress, [123n] );

See also: Get Accounts Factory

Last updated on