SystemInstruction.createAccountWithSeed constructor

SystemInstruction.createAccountWithSeed({
  1. required Ed25519HDPublicKey fundingAccount,
  2. required Ed25519HDPublicKey newAccount,
  3. required Ed25519HDPublicKey base,
  4. required String seed,
  5. required int lamports,
  6. required int space,
  7. required Ed25519HDPublicKey owner,
})

Create a new account at an address derived from a base pubkey and a seed.

Implementation

factory SystemInstruction.createAccountWithSeed({
  required Ed25519HDPublicKey fundingAccount,
  required Ed25519HDPublicKey newAccount,
  required Ed25519HDPublicKey base,
  required String seed,
  required int lamports,
  required int space,
  required Ed25519HDPublicKey owner,
}) =>
    SystemInstruction._(
      accounts: [
        AccountMeta.writeable(pubKey: fundingAccount, isSigner: true),
        AccountMeta.writeable(pubKey: newAccount, isSigner: false),
        AccountMeta.readonly(pubKey: base, isSigner: true),
      ],
      data: ByteArray.merge([
        SystemProgram.createAccountWithSeedInstructionIndex,
        base.toByteArray(),
        ByteArray.fromString(seed),
        ByteArray.u64(lamports),
        ByteArray.u64(space),
        owner.toByteArray(),
      ]),
    );