createTokenMetadata static method
Create token metadata for the stake-pool token in the metaplex-token program.
Keys:
[]
stakePoolAddress
- Stake pool.[s]
manager
- Manager.[]
withdrawAuthority
- Stake pool withdraw authority.[]
poolMint
- Pool token mint account.[s, w]
payer
- Payer for creation of token metadata account.[w]
tokenMetadataAccount
- Token metadata account.
Data:
name
- Token name.symbol
- Token symbol e.g.stkSOL
.uri
- URI of the uploaded metadata of the spl-token.
Implementation
static TransactionInstruction createTokenMetadata({
// Keys
required final Pubkey stakePoolAddress,
required final Pubkey manager,
required final Pubkey withdrawAuthority,
required final Pubkey poolMint,
required final Pubkey payer,
required final Pubkey tokenMetadataAccount,
// Data
required final String name,
required final String symbol,
required final String uri,
}) {
// 0. `[]` Stake pool
// 1. `[s]` Manager
// 2. `[]` Stake pool withdraw authority
// 3. `[]` Pool token mint account
// 4. `[s, w]` Payer for creation of token metadata account
// 5. `[w]` Token metadata account
// 6. `[]` Metadata program id
// 7. `[]` System program id
// 8. `[]` Rent sysvar
final List<AccountMeta> keys = [
AccountMeta(stakePoolAddress),
AccountMeta.signer(manager),
AccountMeta(withdrawAuthority),
AccountMeta(poolMint),
AccountMeta.signerAndWritable(payer),
AccountMeta.writable(tokenMetadataAccount),
AccountMeta(MetaplexTokenMetadataProgram.programId),
AccountMeta(SystemProgram.programId),
AccountMeta(sysvarRentPubkey),
];
final BorshStringCodec rustString = borsh.rustString();
final List<Iterable<int>> data = [
rustString.encode(name),
rustString.encode(symbol),
rustString.encode(uri),
];
return _instance.createTransactionIntruction(
StakePoolInstruction.createTokenMetadata,
keys: keys,
data: data,
);
}