createPoolTokenMetadata static method
Future<List<TransactionInstruction> >
createPoolTokenMetadata({
- required SolanaRPC rpc,
- required SolAddress stakePoolAddress,
- required SolAddress payer,
- required String name,
- required String symbol,
- required String uri,
Creates instructions required to create pool token metadata.
Implementation
static Future<List<TransactionInstruction>> createPoolTokenMetadata({
required SolanaRPC rpc,
required SolAddress stakePoolAddress,
required SolAddress payer,
required String name,
required String symbol,
required String uri,
}) async {
final stakePool = await rpc
.request(SolanaRPCGetStakePoolAccount(address: stakePoolAddress));
if (stakePool == null) {
throw MessageException("Stake pool account does not found.");
}
final withdrawAuthority =
StakePoolProgramUtils.findWithdrawAuthorityProgramAddress(
stakePoolAddress: stakePoolAddress,
);
final tokenMetadata = StakePoolProgramUtils.findMetadataAddress(
stakePoolMintAddress: stakePool.poolMint);
final instructions = <TransactionInstruction>[];
instructions.add(
StakePoolProgram.createTokenMetadata(
stakePool: stakePoolAddress,
poolMint: stakePool.poolMint,
payer: payer,
manager: stakePool.manager,
tokenMetadata: tokenMetadata.address,
withdrawAuthority: withdrawAuthority.address,
layout: StakePoolCreateTokenMetaDataLayout(
name: name, uri: uri, symbol: symbol)),
);
return instructions;
}