ctor.rs 1.1 KB

123456789101112131415161718192021222324252627
  1. use crate::{Accounts, ToAccountInfo};
  2. use solana_program::account_info::AccountInfo;
  3. /// The Ctor accounts that can be used to create any account within the program
  4. /// itself (instead of creating the account on the client).
  5. ///
  6. /// This is used to create accounts at deterministic addresses, as a function of
  7. /// nothing but a program ID--for example, to create state global program
  8. /// structs and program IDL accounts. It's currently used **internally** within
  9. /// the Anchor `#[program]` codegen.
  10. #[derive(Accounts)]
  11. pub struct Ctor<'info> {
  12. // Payer of the transaction.
  13. #[account(signer)]
  14. pub from: AccountInfo<'info>,
  15. // The deterministically defined "state" account being created via
  16. // `create_account_with_seed`.
  17. #[account(mut)]
  18. pub to: AccountInfo<'info>,
  19. // The program-derived-address signing off on the account creation.
  20. // Seeds = &[] + bump seed.
  21. pub base: AccountInfo<'info>,
  22. // The system program.
  23. pub system_program: AccountInfo<'info>,
  24. // The program whose state is being constructed.
  25. pub program: AccountInfo<'info>,
  26. }