-
Notifications
You must be signed in to change notification settings - Fork 60
Document Bubblegum V2 sfbp inheritance #533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MarkSackerberg
wants to merge
7
commits into
main
Choose a base branch
from
feat/bgumInheritSfbp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5a67c0b
document sfbp inheritance
MarkSackerberg d7407b8
translations
MarkSackerberg c2944d1
detail explanation
MarkSackerberg bc38101
updated approach
MarkSackerberg 6507bec
fix build
MarkSackerberg b5a6e33
Document DAS _raw inherited royalty fields
MarkSackerberg 7a69c71
Rename royalty.sfbp_inherited to royalty.inherited in docs
MarkSackerberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/examples/bubblegum/get-asset-with-proof-inherited/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /** | ||
| * Example: getAssetWithProof with inherited royalties | ||
| * | ||
| * Leaf metadata keeps the on-chain sentinel; DAS main royalty fields hold the collection-resolved display rate. | ||
| * | ||
| * This file is auto-generated by scripts/build-examples.js | ||
| * Edit the native .js/.ts and .rs files, then run: node scripts/build-examples.js | ||
| */ | ||
|
|
||
| const umiSections = { | ||
| "imports": "import { getAssetWithProof, mplBubblegum } from '@metaplex-foundation/mpl-bubblegum'\nimport { publicKey } from '@metaplex-foundation/umi'\nimport { createUmi } from '@metaplex-foundation/umi-bundle-defaults'", | ||
| "setup": "const umi = createUmi('https://api.devnet.solana.com').use(mplBubblegum())\n\nconst assetId = publicKey('YOUR_ASSET_ID')", | ||
| "main": "const assetWithProof = await getAssetWithProof(umi, assetId, {\n truncateCanopy: true,\n})\n\n// Leaf / hashing value (65535 when inherited)\nconsole.log(assetWithProof.metadata.sellerFeeBasisPoints)\n\n// Display / payout value from DAS main fields\nconsole.log(assetWithProof.rpcAsset.royalty?.basis_points)", | ||
| "output": "// 65535\n// 500", | ||
| "full": "// [IMPORTS]\nimport { getAssetWithProof, mplBubblegum } from '@metaplex-foundation/mpl-bubblegum'\nimport { publicKey } from '@metaplex-foundation/umi'\nimport { createUmi } from '@metaplex-foundation/umi-bundle-defaults'\n// [/IMPORTS]\n\n// [SETUP]\nconst umi = createUmi('https://api.devnet.solana.com').use(mplBubblegum())\n\nconst assetId = publicKey('YOUR_ASSET_ID')\n// [/SETUP]\n\n// [MAIN]\nconst assetWithProof = await getAssetWithProof(umi, assetId, {\n truncateCanopy: true,\n})\n\n// Leaf / hashing value (65535 when inherited)\nconsole.log(assetWithProof.metadata.sellerFeeBasisPoints)\n\n// Display / payout value from DAS main fields\nconsole.log(assetWithProof.rpcAsset.royalty?.basis_points)\n// [/MAIN]\n\n// [OUTPUT]\n// 65535\n// 500\n// [/OUTPUT]\n" | ||
| } | ||
|
|
||
| export const metadata = { | ||
| title: "getAssetWithProof with inherited royalties", | ||
| description: "Leaf metadata keeps the on-chain sentinel; DAS main royalty fields hold the collection-resolved display rate.", | ||
| tags: [], | ||
| } | ||
|
|
||
| export const examples = { | ||
| umi: { | ||
| framework: 'Umi', | ||
| language: 'typescript', | ||
| code: umiSections.full, | ||
| sections: umiSections, | ||
| }, | ||
|
|
||
| } | ||
28 changes: 28 additions & 0 deletions
28
src/examples/bubblegum/get-asset-with-proof-inherited/umi.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // [IMPORTS] | ||
| import { getAssetWithProof, mplBubblegum } from '@metaplex-foundation/mpl-bubblegum' | ||
| import { publicKey } from '@metaplex-foundation/umi' | ||
| import { createUmi } from '@metaplex-foundation/umi-bundle-defaults' | ||
| // [/IMPORTS] | ||
|
|
||
| // [SETUP] | ||
| const umi = createUmi('https://api.devnet.solana.com').use(mplBubblegum()) | ||
|
|
||
| const assetId = publicKey('YOUR_ASSET_ID') | ||
| // [/SETUP] | ||
|
|
||
| // [MAIN] | ||
| const assetWithProof = await getAssetWithProof(umi, assetId, { | ||
| truncateCanopy: true, | ||
| }) | ||
|
|
||
| // Leaf / hashing value (65535 when inherited) | ||
| console.log(assetWithProof.metadata.sellerFeeBasisPoints) | ||
|
|
||
| // Display / payout value from DAS main fields | ||
| console.log(assetWithProof.rpcAsset.royalty?.basis_points) | ||
| // [/MAIN] | ||
|
|
||
| // [OUTPUT] | ||
| // 65535 | ||
| // 500 | ||
| // [/OUTPUT] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // [IMPORTS] | ||
| import { createTreeV2, mintV2, mplBubblegum } from '@metaplex-foundation/mpl-bubblegum' | ||
| import { createCollection, mplCore, ruleSet } from '@metaplex-foundation/mpl-core' | ||
| import { generateSigner, some } from '@metaplex-foundation/umi' | ||
| import { createUmi } from '@metaplex-foundation/umi-bundle-defaults' | ||
| // [/IMPORTS] | ||
|
|
||
| // [SETUP] | ||
| const umi = createUmi('https://api.devnet.solana.com') | ||
| .use(mplBubblegum()) | ||
| .use(mplCore()) | ||
|
|
||
| const merkleTree = generateSigner(umi) | ||
| const collectionSigner = generateSigner(umi) | ||
|
|
||
| await createTreeV2(umi, { | ||
| merkleTree, | ||
| maxDepth: 5, | ||
| maxBufferSize: 8, | ||
| }).sendAndConfirm(umi) | ||
|
|
||
| // The collection must include BubblegumV2 and Royalties plugins. | ||
| await createCollection(umi, { | ||
| collection: collectionSigner, | ||
| name: 'My Collection', | ||
| uri: 'https://example.com/collection.json', | ||
| plugins: [ | ||
| { type: 'BubblegumV2' }, | ||
| { | ||
| type: 'Royalties', | ||
| basisPoints: 500, // 5% | ||
| creators: [{ address: umi.identity.publicKey, percentage: 100 }], | ||
| ruleSet: ruleSet('None'), | ||
| }, | ||
| ], | ||
| }).sendAndConfirm(umi) | ||
| // [/SETUP] | ||
|
|
||
| // [MAIN] | ||
| // sellerFeeBasisPoints is omitted — the SDK sends the inherit sentinel (65535). | ||
| await mintV2(umi, { | ||
| collectionAuthority: umi.identity, | ||
| leafOwner: umi.identity.publicKey, | ||
| merkleTree: merkleTree.publicKey, | ||
| coreCollection: collectionSigner.publicKey, | ||
| metadata: { | ||
| name: 'My NFT', | ||
| uri: 'https://example.com/my-nft.json', | ||
| collection: some(collectionSigner.publicKey), | ||
| creators: [], // must be empty when inheriting royalties | ||
| }, | ||
| }).sendAndConfirm(umi) | ||
| // [/MAIN] | ||
|
|
||
| // [OUTPUT] | ||
| // cNFT minted with SELLER_FEE_BASIS_POINTS_INHERIT (65535) on the leaf | ||
| // [/OUTPUT] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // [IMPORTS] | ||
| import { | ||
| getAssetWithProof, | ||
| updateMetadataV2, | ||
| UpdateArgsArgs, | ||
| mplBubblegum, | ||
| } from '@metaplex-foundation/mpl-bubblegum' | ||
| import { publicKey, some } from '@metaplex-foundation/umi' | ||
| import { createUmi } from '@metaplex-foundation/umi-bundle-defaults' | ||
| // [/IMPORTS] | ||
|
|
||
| // [SETUP] | ||
| const umi = createUmi('https://api.devnet.solana.com').use(mplBubblegum()) | ||
|
|
||
| const assetId = publicKey('YOUR_ASSET_ID') | ||
| const collectionPublicKey = publicKey('YOUR_COLLECTION_ADDRESS') | ||
| // [/SETUP] | ||
|
|
||
| // [MAIN] | ||
| const assetWithProof = await getAssetWithProof(umi, assetId, { | ||
| truncateCanopy: true, | ||
| }) | ||
|
|
||
| // Switch from inherited royalties to an explicit seller fee before removing | ||
| // the cNFT from its collection. | ||
| const updateArgs: UpdateArgsArgs = { | ||
| sellerFeeBasisPoints: some(550), // explicit 5.5% | ||
| } | ||
|
|
||
| await updateMetadataV2(umi, { | ||
| ...assetWithProof, | ||
| currentMetadata: { | ||
| name: assetWithProof.metadata.name, | ||
| symbol: assetWithProof.metadata.symbol, | ||
| uri: assetWithProof.metadata.uri, | ||
| sellerFeeBasisPoints: assetWithProof.metadata.sellerFeeBasisPoints, | ||
| primarySaleHappened: assetWithProof.metadata.primarySaleHappened, | ||
| isMutable: assetWithProof.metadata.isMutable, | ||
| tokenStandard: assetWithProof.metadata.tokenStandard, | ||
| creators: assetWithProof.metadata.creators, | ||
| collection: some(collectionPublicKey), | ||
| }, | ||
| updateArgs, | ||
| coreCollection: collectionPublicKey, | ||
| }).sendAndConfirm(umi) | ||
| // [/MAIN] | ||
|
|
||
| // [OUTPUT] | ||
| // Leaf seller fee updated from inherit sentinel (65535) to 550 basis points | ||
| // [/OUTPUT] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: metaplex-foundation/developer-hub
Length of output: 434
🏁 Script executed:
Repository: metaplex-foundation/developer-hub
Length of output: 28093
🌐 Web query:
Metaplex Bubblegum v2 getAssetWithProof API getAssetAssetProof DAS required provider api.devnet.solana.com DAS💡 Result:
The
getAssetWithProoffunction is a helper method provided by the@metaplex-foundation/mpl-bubblegumlibrary (part of the Umi framework) designed to simplify interactions with compressed NFTs (cNFTs) [1][2][3]. It automatically fetches both the asset data (viagetAsset) and the Merkle tree proof (viagetAssetProof) from the Metaplex Digital Asset Standard (DAS) API and formats them into the specific parameters required for Bubblegum V2 write instructions, such as transfers, burns, or updates [1][4][5]. Key technical points regarding your query: 1. Usage and Requirements: You should callgetAssetWithProofimmediately before any mutation instruction to avoid using stale proof data [1]. When using the Bubblegum Umi library, register the DAS API plugin (.use(dasApi())) to enable the required RPC methods [1][6]. 2. DAS API Providers: The URLapi.devnet.solana.comis the standard Solana Devnet RPC endpoint, but it does not natively support Metaplex DAS API methods (likegetAssetorgetAssetProof) unless the provider explicitly includes DAS support [1][7]. Most developers use specialized RPC providers (such as Helius, Triton, or Shyft) that offer a specific "Digital Asset Standard (DAS)" API endpoint to handle these requests [8][6]. You must configure your Umi instance to point to an RPC provider that supports the DAS method set [6]. 3. Optimization: If you encounter transaction size limitations, you can use thetruncateCanopy: trueoption withingetAssetWithProof[5][9]. This optimizes the proof path by removing redundant nodes based on the tree's canopy configuration, helping to keep transaction sizes within protocol limits [5]. Example of basic usage: import { getAssetWithProof, transferV2 } from '@metaplex-foundation/mpl-bubblegum'; import { publicKey } from '@metaplex-foundation/umi'; // Fetch proof and asset data const assetWithProof = await getAssetWithProof(umi, assetId, { truncateCanopy: true }); // Use in write operation await transferV2(umi, {...assetWithProof, leafOwner: umi.identity, newLeafOwner: publicKey('NewOwnerAddress'), }).sendAndConfirm(umi);Citations:
Use a DAS endpoint or DAS plugin in the inherited-royalty examples.
Both examples pass
umiintogetAssetWithProof, which needsgetAsset/getAssetProof(Metaplex DAS) rather than only the standard Solana RPC methods. Replaceapi.devnet.solana.comwith a DAS-enabled URL, or add a DAS/UMI DAS plugin setup, then regenerate the JavaScript files.src/examples/bubblegum/get-asset-with-proof-inherited/index.js#L12-L13src/examples/bubblegum/update-inherit-royalties/index.js#L12-L13📍 Affects 2 files
src/examples/bubblegum/get-asset-with-proof-inherited/index.js#L12-L13(this comment)src/examples/bubblegum/update-inherit-royalties/index.js#L12-L13🤖 Prompt for AI Agents