-
Notifications
You must be signed in to change notification settings - Fork 47
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
converted bubblegum to sdk pages #327
Open
tonyboylehub
wants to merge
3
commits into
main
Choose a base branch
from
bubblegum/sdk
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
3 commits
Select commit
Hold shift + click to select a range
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 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 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,15 @@ | ||
--- | ||
title: MPL-Bubblegum SDKs | ||
metaTitle: SDKs | Bubblegum | ||
description: Learn to get started with the compressed NFT standard (cNFT) from Metaplex using the MPL-Bubblegum SDKs. | ||
--- | ||
|
||
Select the language / library you want to use below to get started with the new Metaplex Compressed NFT (cNFT) standard using MPL-Bubblegum. | ||
|
||
{% quick-links %} | ||
|
||
{% quick-link title="JavaScript" icon="JavaScript" href="/bubblegum/sdk/javascript" description="Get started with our JavaScript library for MPL-Bubblegum based on the Umi framework." /%} | ||
|
||
{% quick-link title="Rust" icon="Rust" href="/bubblegum/sdk/rust" description="Get started using our MPL-Bubblegum Rust crate." /%} | ||
|
||
{% /quick-links %} |
This file contains 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,49 @@ | ||
--- | ||
title: MPL-Bubblegum Javascript SDK | ||
metaTitle: Javascript SDK | MPL-Bubblegum | ||
description: Learn how to set up your project to run the MPL-Bubblegum Javascript SDK. | ||
--- | ||
|
||
Metaplex provides a JavaScript library that can be used to interact with the MPL-Bubblegum program. Thanks to the [Umi Framework](/umi), it ships without many opinionated dependencies thus providing a lightweight library that can be used in any JavaScript project. | ||
|
||
To get started, you'll need to [install the Umi framework](/umi/getting-started) and the MPL-Bubblegum JavaScript library. | ||
|
||
## Installation | ||
|
||
Installation can be executed with any of the JS package managers, npm, yarn, bun etc... | ||
|
||
```sh | ||
npm install @metaplex-foundation/mpl-bubblegum | ||
``` | ||
|
||
{% quick-links %} | ||
|
||
{% quick-link title="typedoc" target="_blank" icon="JavaScript" href="https://mpl-bubblegum.typedoc.metaplex.com/" description="MPL-Bubblegum Javascript SDK generated package API documentation." /%} | ||
|
||
{% quick-link title="npmjs.com" target="_blank" icon="JavaScript" href="https://www.npmjs.com/package/@metaplex-foundation/MPL-Bubblegum" description="MPL-Bubblegum Javascript SDK on NPM." /%} | ||
|
||
{% /quick-links %} | ||
|
||
## Umi Setup | ||
|
||
An `umi` instance is required to interact with the Metaplex Javascript SDKs. If you haven't set up and configured an `umi` instance yet then you can checkout the [Umi Getting Started](/umi/getting-started) page and configure your RPC endpoint and your `umi` identity/signer. | ||
|
||
During the initialization of the `umi` instance you can add the MPL-Bubblegum package to `umi` using | ||
|
||
```js | ||
.use(mplCore()) | ||
``` | ||
|
||
You can add the `mplBubblegum()` package anywhere in your umi instance creation with `umi.use(mplBubblegum())`. | ||
|
||
```ts | ||
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults' | ||
import { mplBubblegum } from '@metaplex-foundation/mpl-bubblegum' | ||
|
||
// Use the RPC endpoint of your choice. | ||
const umi = createUmi('http://api.devnet.solana.com') | ||
... // additional umi settings, packages, and signers | ||
.use(mplBubblegum()) | ||
``` | ||
|
||
From here your `umi` instance will have access to the MPL-Bubblegum package and you start to explore the MPL-Bubblegum feature set. |
This file contains 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,118 @@ | ||
--- | ||
title: MPL-Bubblegum Rust SDK | ||
metaTitle: Rust SDK | MPL-Bubblegum | ||
description: Learn how to set up your project to run the MPL-Bubblegum Rust SDK. | ||
--- | ||
|
||
Metaplex provides a Rust library that can be used to interact with the MPL-Bubblegum program. The Rust library can be used in rust scripts/builds as well as onchain programs via CPI instructions. | ||
|
||
## Installation | ||
|
||
The MPL-Bubblegum Rust SDK can be used in both scripts/desktop/mobile applications as well as with Solana onchain programs. | ||
|
||
```rust | ||
cargo add mpl-bubblegum | ||
``` | ||
|
||
{% quick-links %} | ||
|
||
{% quick-link title="crates.io" target="_blank" icon="Rust" href="https://crates.io/crates/mpl-bubblegum" description="Get started with our MPL-Bubblegum Rust crate." /%} | ||
|
||
{% quick-link title="docs.rs" target="_blank" icon="Rust" href="https://docs.rs/MPL-Bubblegum/latest/mpl_bubblegum/" description="The Rust SDK typedoc platform for MPL-Bubblegum." /%} | ||
|
||
{% /quick-links %} | ||
|
||
## Local Scripts | ||
|
||
For local scripts is recommended to use the `Builder` versions of all the instructions listed. These builders abstract a lot of the work for you and return a instruction that can be added to a transaction. | ||
|
||
A list of all Bubblegum instructions can be found here: [MPL-Bubblegum - Rust Instructions](https://docs.rs/mpl-bubblegum/latest/mpl_bubblegum/instructions/index.html) | ||
|
||
For a more comprehensive guide on using Rust check out the [Metaplex Rust SDKs Guide](/guides/rust/metaplex-rust-sdks) page. | ||
|
||
#### CreateTreeConfigBuilder - Example | ||
|
||
```rust | ||
use mpl_bubblegum::{instructions::CreateTreeConfigBuilder, programs::{SPL_ACCOUNT_COMPRESSION_ID, SPL_NOOP_ID}}; | ||
use solana_client::{nonblocking::rpc_client, rpc_config::RpcSendTransactionConfig}; | ||
use solana_sdk::{commitment_config::CommitmentConfig, pubkey::Pubkey, signature::Keypair, signer::Signer, system_program, transaction::Transaction}; | ||
|
||
#[tokio::main] | ||
pub async fn create_tree(keypair: Keypair) { | ||
let rpc_client = rpc_client::RpcClient::new("https://devnet.helius-rpc.com/?api-key=555f20ad-afaf-4a78-a889-244f281ab399".to_string()); | ||
|
||
let payer = keypair; | ||
|
||
|
||
let asset = Keypair::new(); | ||
|
||
let merkle_tree = Keypair::new(); | ||
|
||
let tree_config = Pubkey::find_program_address( | ||
&[ | ||
&merkle_tree.pubkey().to_bytes(), | ||
], | ||
&mpl_bubblegum::ID, | ||
); | ||
|
||
let create_tree_config_ix = CreateTreeConfigBuilder::new() | ||
.merkle_tree(merkle_tree.pubkey()) | ||
.tree_config(tree_config.0) | ||
.payer(payer.pubkey()) | ||
.log_wrapper(SPL_NOOP_ID) | ||
.compression_program(SPL_ACCOUNT_COMPRESSION_ID) | ||
.system_program(system_program::ID) | ||
.max_depth(20) | ||
.max_buffer_size(1024) | ||
.public(false) | ||
.instruction(); | ||
|
||
let signers = vec![&asset, &payer]; | ||
|
||
let last_blockhash = rpc_client.get_latest_blockhash().await; | ||
|
||
let create_tree_config_tx = Transaction::new_signed_with_payer( | ||
&[create_tree_config_ix], | ||
Some(&payer.pubkey()), | ||
&signers, | ||
last_blockhash.unwrap(), | ||
); | ||
|
||
let res = rpc_client | ||
.send_transaction_with_config(&create_tree_config_tx, RpcSendTransactionConfig { | ||
skip_preflight: false, | ||
preflight_commitment: Some(CommitmentConfig::confirmed().commitment), | ||
encoding: None, | ||
max_retries: None, | ||
min_context_slot: None, | ||
}) | ||
.await | ||
.unwrap(); | ||
|
||
println!("Signature: {:?}", res) | ||
} | ||
``` | ||
|
||
## CPI (Cross Program Invocation) | ||
|
||
Performing CPI instructions from your own programs can be achieved easily by using the `CpiBuilder` version of an instruction function that can be found for all instructions in the `MPL-Bubblegum` Rust crate. | ||
|
||
A list of all Bubblegum instructions can be found here: [Metaplex Bubblegum - Rust Instructions](https://docs.rs/mpl-bubblegum/latest/mpl_bubblegum/instructions/index.html) | ||
|
||
For a more comprehensive guide using Metaplex crates to create CPI instructions check out the [How to CPI into a Metaplex Program guide](/guides/rust/how-to-cpi-into-a-metaplex-program) page. | ||
|
||
#### CreateTreeConfigCpiBuilder - Example | ||
|
||
```rust | ||
CreateTreeConfigCpiBuilder::new() | ||
.merkle_tree(context.accounts.merkle_tree) | ||
.tree_config(context.accounts.tree_config) | ||
.payer(context.accounts.payer) | ||
.tree_creator(context.accounts.tree_creator) | ||
.log_wrapper(SPL_NOOP_ID) | ||
.compression_program(context.accounts.compression_program) | ||
.system_program(context.acccounts.system_program) | ||
.max_depth(20) | ||
.max_bufferisz(1024) | ||
.public(false) | ||
.invoke() | ||
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.
Something is wrong here i think?
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.
Believe I messaged you on slack about this. Can this be double checked?
When pulling the actual file the closing ``` seems to be there. Not sure whey it's not showing in github online.