createWithSeed static method

Pubkey createWithSeed(
  1. Pubkey pubkey,
  2. String seed,
  3. Pubkey programId
)

Derives a Pubkey from another pubkey, seed, and programId.

The program Id will also serve as the owner of the public key, giving it permission to write data to the account.

Implementation

static Pubkey createWithSeed(
  final Pubkey pubkey,
  final String seed,
  final Pubkey programId,
) {
  final Uint8List seedBytes = Uint8List.fromList(utf8.encode(seed));
  final List<int> buffer = pubkey.toBytes() + seedBytes + programId.toBytes();
  return Pubkey.fromUint8List(sha256.convert(buffer).bytes);
}