createProgramAddress static method

SolAddress createProgramAddress({
  1. required List<int> seedBytes,
  2. required SolAddress programId,
})

Finds a program address for the given seeds and program ID.

Implementation

static SolAddress createProgramAddress(
    {required List<int> seedBytes, required SolAddress programId}) {
  seedBytes = [
    ...seedBytes,
    ...programId.toBytes(),
    ...programDerivedAddressSeed.codeUnits
  ];

  seedBytes = QuickCrypto.sha256Hash(seedBytes);
  if (Ed25519PublicKey.isValidBytes(seedBytes)) {
    throw const MessageException(
        "Invalid seeds, address must fall off the curve");
  }
  return SolAddress.uncheckBytes(seedBytes);
}