1

I'm using Metaplex's Umi library to work with pNFTs via a custom program that I built, and one of the required accounts for most instructions is the Authorization Rules (& auth rules program). Theoretically, the instructions will work if I upgrade the program to omit these accounts, but then the program will lack coverage for many collections.

How can I fetch the authorization rules account for a given pNFT?

1 Answer 1

3

You can access the authentication rules for a given pNFT by inspecting the token's metadata account. This can be done with umi, and mpl-token-metadata. Fetching the PDA and it's data will look something like this:

const nftMetadata = findMetadataPda(umi, { mint: publicKey(nftMint) });

const metadataInfo = await fetchMetadata(umi, publicKey(nftMetadata));

The 'metadataInfo' object will include a 'programmableConfig' field, which will contain the ruleSet account. You can access it with the following:

//@ts-ignore
const ruleSet = metadataInfo.programmableConfig.value.ruleSet.value;

Typescript doesn't like this because it uses an Option type (sometimes pNFTs won't have rulesets associated with them), hence the ts-ignore. Not perfect, but works in my case :)

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.