findProgramAddress static method
Tuple<SolAddress, int>
findProgramAddress({
- required List<
List< seeds,int> > - required SolAddress programId,
Converts a Solana value to lamports.
Implementation
static Tuple<SolAddress, int> findProgramAddress(
{required List<List<int>> seeds, required SolAddress programId}) {
int nonce = 255;
List<int> seedBytes = [];
for (final i in seeds) {
if (i.length > maxSeedLength) {
throw const MessageException("Max seed length exceeded");
}
seedBytes = [...seedBytes, ...i];
}
while (nonce != 0) {
try {
final List<int> seedsWithNonce = [...seedBytes, nonce];
final addr = createProgramAddress(
seedBytes: seedsWithNonce, programId: programId);
return Tuple(addr, nonce);
} catch (e) {
nonce--;
continue;
}
}
throw const MessageException(
"Unable to find a viable program address nonce");
}