rent.sol 970 B

1234567891011121314151617181920212223242526
  1. import "../libraries/system_instruction.sol";
  2. import '../libraries/minimum_balance.sol';
  3. @program_id("F1ipperKF9EfD821ZbbYjS319LXYiBmjhzkkf5a26rC")
  4. contract rent {
  5. @payer(payer) // The "payer" pays for the data account creation
  6. constructor() {}
  7. @mutableSigner(payer)
  8. @mutableSigner(newAccount)
  9. function createSystemAccount(uint64 space) external {
  10. // The minimum lamports required for the amount of space allocated to the account
  11. uint64 lamports = minimum_balance(space);
  12. SystemInstruction.create_account(
  13. tx.accounts.payer.key, // lamports sent from this account (payer)
  14. tx.accounts.newAccount.key, // lamports sent to this account (account to be created)
  15. lamports, // lamport amount (minimum lamports required)
  16. space, // space required for the account
  17. SystemInstruction.systemAddress // program owner (system program)
  18. );
  19. }
  20. }