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 fromseeds:Array<String | Address | BigInt | Uint8Array>- Array of seeds to derive the PDA. Can be a mix of:string- Will be encoded as UTF-8 bytesAddress- Will be encoded as a Solana addressBigInt- Will be encoded as 8-byte little-endian bytesUint8Array- Will be used as-is (for custom encoding strategies)
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