> For the complete documentation index, see [llms.txt](https://docs.seabed.so/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.seabed.so/open-source-primitives/pre-authorized-debit-v1/program/account-model/smart-delegate.md).

# Smart Delegate

```rust
// PDA Seeds: ['smart-delegate']
pub struct SmartDelegate {
    pub bump: u8, // The canocial bump in the PDA seed
}
```

The Smart Delegate account ([github](https://github.com/seabed-labs/pre-authorized-debit/blob/main/programs/pre-authorized-debit-v1/src/state/smart_delegate.rs)) is a singleton PDA of the program. For a pre-authorization to be usable, this account needs to be set as the token account's delegate ([token program github](https://github.com/solana-labs/solana-program-library/blob/master/token/program/src/state.rs#L95), [token2022 program github](https://github.com/solana-labs/solana-program-library/blob/master/token/program-2022/src/state.rs#L101)) and the delegate\_amount needs to be set to `u64::MAX`. This is so that the program can sign on behalf of a valid pre-authorization to transfer/debit the funds via the SPL Token / Token2022 program. This delegation inherits the security guarantees of the pre-authorized-debit-v1 program as the program itself is not upgradeable (note: the mainnet program will remain upgradeable until we finish the SDK and UI to allow for any bug/vulnerabity fixes that might be discovered by then but the devnet program is already frozen).

For each instance of the program (i.e. mainnet and devnet), our team has already initialized the smart\_delegate accounts and the addresses are below:

* Mainnet: `5xwfb7dPwdbgnMFABbF9mqYaD79ocSngiR9GMSY9Tfzb`
* Devnet: `5xwfb7dPwdbgnMFABbF9mqYaD79ocSngiR9GMSY9Tfzb`

Our SDK (currently WIP) will expose convenience methods to set the delegate of a token account to this smart delegate PDA with the appropriate amount.
