updateTokenMetadata static method

TransactionInstruction updateTokenMetadata({
  1. required Pubkey stakePoolAddress,
  2. required Pubkey manager,
  3. required Pubkey withdrawAuthority,
  4. required Pubkey tokenMetadataAccount,
  5. required String name,
  6. required String symbol,
  7. required String uri,
})

Update token metadata for the stake-pool token in the metaplex-token program.

  1. [] stakePoolAddress - Stake pool.
  2. [s] manager - Manager.
  3. [] withdrawAuthority - Stake pool withdraw authority.
  4. [w] tokenMetadataAccount - Token metadata account.

Implementation

static TransactionInstruction updateTokenMetadata({
  // Keys
  required final Pubkey stakePoolAddress,
  required final Pubkey manager,
  required final Pubkey withdrawAuthority,
  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. `[w]` Token metadata account
  // 4. `[]` Metadata program id
  final List<AccountMeta> keys = [
    AccountMeta(stakePoolAddress),
    AccountMeta.signer(manager),
    AccountMeta(withdrawAuthority),
    AccountMeta.writable(tokenMetadataAccount),
    AccountMeta(MetaplexTokenMetadataProgram.programId),
  ];

  final BorshStringCodec rustString = borsh.rustString();
  final List<Iterable<int>> data = [
    rustString.encode(name),
    rustString.encode(symbol),
    rustString.encode(uri),
  ];

  return _instance.createTransactionIntruction(
    StakePoolInstruction.updateTokenMetadata,
    keys: keys,
    data: data,
  );
}