Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Remove pa #694

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions docs/toolkit/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Signer<'info>>,

// 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
Expand Down
Loading