diff --git a/docs/toolkit/best-practices.md b/docs/toolkit/best-practices.md index 28c16507a..dfce7c7e4 100644 --- a/docs/toolkit/best-practices.md +++ b/docs/toolkit/best-practices.md @@ -54,51 +54,6 @@ transaction failure, and consistency across invocations. - [PDA Bumps Core Concepts](/docs/core/pda.md#canonical-bump) - [Bump Seed Canonicalization Lesson](https://solana.com/developers/courses/program-security/bump-seed-canonicalization) -## Payer-Authority Pattern - -The Payer-Authority pattern is an elegant way to handle situations where the -account’s funder (payer) differs from the account’s owner or manager -(authority). By requiring separate signers and validating them in your onchain -logic, you can maintain clear, robust, and flexible ownership semantics in your -program. - -### Shank Example - -```rust -// Create a new account. -#[account(0, writable, signer, name="account", desc = "The address of the new account")] -#[account(1, writable, signer, name="payer", desc = "The account paying for the storage fees")] -#[account(2, optional, signer, name="authority", desc = "The authority signing for the account creation")] -#[account(3, name="system_program", desc = "The system program")] -CreateAccountV1(CreateAccountV1Args), -``` - -### Anchor Example - -```rust -#[derive(Accounts)] -pub struct CreateAccount<'info> { - /// The address of the new account - #[account(init, payer = payer_one, space = 8 + NewAccount::MAXIMUM_SIZE)] - pub account: Account<'info, NewAccount>, - - /// The account paying for the storage fees - #[account(mut)] - pub payer: Signer<'info>, - - /// The authority signing for the account creation - pub authority: Option>, - - // The system program - pub system_program: Program<'info, System> -} -``` - -### Additional References - -- [Metaplex Guide on Payer-Authority Pattern](https://developers.metaplex.com/guides/general/payer-authority-pattern) -- [Helium Program Library using the Payer-Authority Pattern](https://github.com/helium/helium-program-library/blob/master/programs/data-credits/src/instructions/change_delegated_sub_dao_v0.rs#L18) - ## Invariants Implement invariants, which are functions that you can call at the end of your