What is a Controller?
A Controller is a special on-chain account (PDA) in the Dropsy protocol that acts as the authority root for managing airdrops, enforcing fees, and organizing permissions. Each controller is tied to an initializer (authority) and can manage multiple airdrops.
PDA Derivation (Manual)
Using @solana/kit's primitive:
import { getProgramDerivedAddress, getAddressEncoder } from "@solana/kit";
import { DROPSY_PROGRAM_ADDRESS } from "@dropsy/airdrop";
const [controllerPda, bump] = await getProgramDerivedAddress({
seeds: [
Buffer.from("controller"),
getAddressEncoder().encode(authorityAddress),
],
programAddress: DROPSY_PROGRAM_ADDRESS,
});
PDA Derivation (Recommended)
Using @dropsy/airdrop's built-in helper:
import { getControllerDerivedAddress } from "@dropsy/airdrop";
const [controllerPda, bump] = await getControllerDerivedAddress(authorityAddress);
The helper method handles seed formatting and program address internally, providing a cleaner interface for common use cases.
Complete Example
Here's how to create a controller PDA from a known private key:
import { createKeyPairSignerFromBytes } from "@solana/kit";
import { getControllerDerivedAddress } from "@dropsy/airdrop";
// Initialize wallet from known private key bytes
const wallet = await createKeyPairSignerFromBytes(
new Uint8Array(
// prettier-ignore
[73, 125, 30, 111, 228, 236, 221, 13, 205, 173, 49, 230, 85, 142, 16, 179, 148, 10, 6, 13, 81, 140, 125, 62, 198, 211, 222, 229, 8, 70, 179, 2, 173, 2, 219, 192, 135, 210, 20, 23, 44, 101, 212, 179, 10, 2, 50, 56, 93, 49, 16, 131, 134, 121, 193, 82, 192, 70, 88, 196, 152, 75, 26, 22]
)
);
// Derive controller PDA
const [controllerPda, bump] = await getControllerDerivedAddress(wallet.address);
console.log(`Controller PDA: ${controllerPda}`);}
Controller Features
- Unique per authority address
- Deterministic derivation (same inputs = same address)
- Manages all airdrops created by the authority
- Enforces protocol fees on distributions