2

I'm using both libraries in my codebase.

Whenever I pass a pubkey to an metaplex method, I sometimes need to convert:

example

import { Umi, publicKey } from '@metaplex-foundation/umi';
import { findAssociatedTokenPda } from '@metaplex-foundation/mpl-toolbox';

~~~~~~~

  const mint = publicKey(mintPublicKey.toBase58());
  const walletAddress = publicKey(wallet.publicKey.toBase58());
  const owner = findAssociatedTokenPda(umi, {
    mint,
    owner: walletAddress,
  });

Is there a built in method so that I don't have to convert to base58 and then call the publicKey fn?

1 Answer 1

5

To convert the public keys, use the fromWeb3JsPublicKey and toWeb3JsPublicKey methods from the @metaplex-foundation/umi-web3js-adapters package.

You can read more on the documentation about the Web3.js adapters in the Umi GitHub repo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.