### Install Project Dependencies Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CONTRIBUTING.md Install all project dependencies using pnpm. Ensure pnpm is installed before running this command. ```sh pnpm install ``` -------------------------------- ### Start Local Validator Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Launches a local Solana validator instance with the core program already deployed. ```bash pnpm validator ``` -------------------------------- ### Install Mpl Core Library Source: https://github.com/metaplex-foundation/mpl-core/blob/main/clients/js/README.md Install the @metaplex-foundation/mpl-core library using npm. ```sh npm install @metaplex-foundation/mpl-core ``` -------------------------------- ### Frontend Wallet Integration with Umi and Mpl Core Source: https://github.com/metaplex-foundation/mpl-core/blob/main/clients/js/README.md Integrate Mpl Core with Umi for frontend applications using wallet adapters. This example shows how to set up Umi with a wallet adapter identity and the mplCore plugin. ```ts import { useConnection, useWallet } from '@solana/wallet-adapter-react'; import { walletAdapterIdentity } from '@metaplex-foundation/umi-signer-wallet-adapters'; export function MyComponent() { const wallet = useWallet(); const { connection } = useConnection(); const umi = createUmi(connection) .use(walletAdapterIdentity(wallet)) .use(mplCore()) // rest of component } ``` -------------------------------- ### Start Local Validator with Debug Logs Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Starts a local Solana validator with detailed logging enabled for debugging purposes. ```bash pnpm validator:debug ``` -------------------------------- ### Build the Client Source: https://github.com/metaplex-foundation/mpl-core/blob/main/clients/js/CONTRIBUTING.md Build the JavaScript client. This command should be run before testing. ```sh # Build the client. pnpm build ``` -------------------------------- ### Test the Client Source: https://github.com/metaplex-foundation/mpl-core/blob/main/clients/js/CONTRIBUTING.md Run all tests for the client. Building the client is a prerequisite. ```sh # Test the client (requires building first). pnpm build && pnpm test ``` -------------------------------- ### Build JS Client Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Navigates to the JavaScript client directory and builds the client library. ```bash cd clients/js && pnpm build ``` -------------------------------- ### Generate Client Libraries Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Generates client libraries from IDL files using the Kinobi tool. ```bash pnpm generate:clients ``` -------------------------------- ### Create, Fetch, and Transfer Assets and Collections Source: https://github.com/metaplex-foundation/mpl-core/blob/main/clients/js/README.md Demonstrates the basic lifecycle of assets and collections, including creation, retrieval, and transfer operations. ```typescript const assetAddress = generateSigner(umi); const owner = generateSigner(umi); await create(umi, { name: 'Test Asset', uri: 'https://example.com/asset.json', asset: assetAddress, owner: owner.publicKey, // optional, will default to payer }).sendAndConfirm(umi); // Fetch an asset const asset = await fetchAssetV1(umi, assetAddress.publicKey); // Create a collection const collectionUpdateAuthority = generateSigner(umi); const collectionAddress = generateSigner(umi); await createCollection(umi, { name: 'Test Collection', uri: 'https://example.com/collection.json', collection: collectionAddress, updateAuthority: collectionUpdateAuthority.publicKey, // optional, defaults to payer }).sendAndConfirm(umi); // Fetch a collection const collection = await fetchCollectionV1(umi, collectionAddress.publicKey); // Create an asset in a collection, the authority must be the updateAuthority of the collection await create(umi, { name: 'Test Asset', uri: 'https://example.com/asset.json', asset: assetAddress, collection, authority: collectionUpdateAuthority, // optional, defaults to payer }).sendAndConfirm(umi); // Transfer an asset const recipient = generateSigner(umi); await transfer(umi, { asset, newOwner: recipient.publicKey, }).sendAndConfirm(umi); // Transfer an asset in a collection await transfer(umi, { asset, newOwner: recipient.publicKey, collection, }).sendAndConfirm(umi); ``` -------------------------------- ### Create Collection with Royalties Source: https://github.com/metaplex-foundation/mpl-core/blob/main/clients/js/README.md Demonstrates creating a collection with a 'Royalties' plugin, specifying basis points and creator percentages. Assets created within this collection will inherit these royalties. ```typescript // Create a collection with royalties const collectionAddress = generateSigner(umi); const creator1 = generateSigner(umi); const creator2 = generateSigner(umi); await createCollection(umi, { name: 'Test Collection', uri: 'https://example.com/collection.json', collection: collectionAddress, plugins: [ { type: 'Royalties', basisPoints: 500, creators: [ { address: creator1.publicKey, percentage: 20, }, { address: creator2.publicKey, percentage: 80, }, ], ruleSet: ruleSet('None'), // Compatibility rule set }, ], }).sendAndConfirm(umi); // Create an asset in a collection. // Assets in a collection will inherit the collection's authority-managed plugins, in this case the royalties plugin await create(umi, { name: 'Test Asset', uri: 'https://example.com/asset.json', asset: assetAddress, collection: await fetchCollectionV1(umi, collectionAddress.publicKey), }).sendAndConfirm(umi); ``` -------------------------------- ### Build All Rust Programs Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Compiles all Rust programs within the repository and fetches necessary dependencies. ```bash pnpm programs:build ``` -------------------------------- ### Build Mpl Core Program Source: https://github.com/metaplex-foundation/mpl-core/blob/main/programs/mpl-core/README.md Builds the program and outputs a .so file for local validator deployment. This command is used to compile the BPF program. ```sh cargo build-bpf ``` -------------------------------- ### Test Specific Files Source: https://github.com/metaplex-foundation/mpl-core/blob/main/clients/js/CONTRIBUTING.md Execute tests for a specific file or a pattern of files. Ensure the client is built first. ```sh pnpm build && pnpm test test/somefile.test.js pnpm build && pnpm test test/somePattern* ``` -------------------------------- ### Generate Clients and IDLs Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CONTRIBUTING.md Generate clients and IDLs for all programs. This command is a shortcut for running both 'pnpm generate:idls' and 'pnpm generate:clients'. Re-run this command when program changes occur. ```sh pnpm generate ``` -------------------------------- ### Test Mpl Core Program Source: https://github.com/metaplex-foundation/mpl-core/blob/main/programs/mpl-core/README.md Builds the program and runs its Rust tests. This command is used to ensure the program's functionality and integrity. ```sh cargo test-bpf ``` -------------------------------- ### Run Rust Client Tests Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Executes the test suite for the Rust client libraries. ```bash pnpm clients:rust:test ``` -------------------------------- ### Query Assets using GPA Builder Source: https://github.com/metaplex-foundation/mpl-core/blob/main/clients/js/README.md Shows how to use the Generic Program Account (GPA) builder to fetch assets based on owner and collection criteria. ```typescript // GPA fetch assets by owner const assetsByOwner = await getAssetV1GpaBuilder(umi) .whereField('key', Key.AssetV1) .whereField('owner', owner.publicKey) .getDeserialized(); // GPA fetch assets by collection const assetsByCollection = await getAssetV1GpaBuilder(umi) .whereField('key', Key.AssetV1) .whereField( 'updateAuthority', updateAuthority('Collection', [collectionAddress.publicKey]) ) .getDeserialized(); ``` -------------------------------- ### Run Specific JS Client Tests Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Navigates to the JavaScript client directory and runs its tests. ```bash cd clients/js && pnpm test ``` -------------------------------- ### Build and Test Rust Client Source: https://github.com/metaplex-foundation/mpl-core/blob/main/clients/rust/CONTRIBUTING.md Use Cargo to build and test the Rust client. Testing requires the program to be built first. ```sh cargo build ``` ```sh cargo test-sbf --sbf-out-dir ../../programs/.bin ``` -------------------------------- ### Run JavaScript Client Tests Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Executes the test suite for the JavaScript client libraries. ```bash pnpm clients:js:test ``` -------------------------------- ### Freeze and Unfreeze Assets with Delegate Authority Source: https://github.com/metaplex-foundation/mpl-core/blob/main/clients/js/README.md Illustrates how to add a 'FreezeDelegate' plugin to an asset, allowing a specified delegate to freeze and unfreeze it. This is useful for escrowless staking. ```typescript const umi = await createUmi(); // Freezing an asset const assetAddress = generateSigner(umi); const freezeDelegate = generateSigner(umi); await addPlugin(umi, { asset: assetAddress.publicKey, // adds the owner-managed freeze plugin to the asset plugin: { type: 'FreezeDelegate', frozen: true, // Optionally set the authority to a delegate who can unfreeze. If unset, this will be the Owner // This is functionally the same as calling addPlugin and approvePluginAuthority separately. // Freezing with a delegate is commonly used for escrowless staking programs. authority: { type: 'Address', address: freezeDelegate.publicKey, }, } }).sendAndConfirm(umi); // Unfreezing an asset with a delegate // Revoking an authority will revert the authority back to the owner for owner-managed plugins await revokePluginAuthority(umi, { asset: assetAddress.publicKey, plugin: { type: 'FreezeDelegate', }, authority: freezeDelegate, }).sendAndConfirm(umi); ``` -------------------------------- ### View Local Validator Logs Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Displays the logs generated by the running local Solana validator. ```bash pnpm validator:logs ``` -------------------------------- ### Run Rust Program Tests Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Executes all unit and integration tests for the Rust programs. ```bash pnpm programs:test ``` -------------------------------- ### Register Mpl Core with Umi Source: https://github.com/metaplex-foundation/mpl-core/blob/main/clients/js/README.md Register the mplCore plugin with your Umi instance. This is required before using any Mpl Core functionalities. ```ts import { createUmi } from '@metaplex-foundation/umi-bundle-defaults'; import { mplCore } from '@metaplex-foundation/mpl-core'; const umi = createUmi(''); umi.use(mplCore()); ``` -------------------------------- ### Run Linting Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Applies linting rules to both JavaScript clients and Rust programs to ensure code quality and consistency. ```bash pnpm lint ``` -------------------------------- ### Run Rust Program Tests with Logs Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Executes Rust program tests while enabling detailed logging for debugging. ```bash pnpm programs:debug ``` -------------------------------- ### Add mpl-core Dependency Source: https://github.com/metaplex-foundation/mpl-core/blob/main/clients/rust/README.md Add the mpl-core crate as a dependency to your Rust project using Cargo. ```bash cargo add mpl-core ``` -------------------------------- ### Generate IDLs from Rust Programs Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Generates IDL files from the Rust programs using the Shank annotation processor. ```bash pnpm generate:idls ``` -------------------------------- ### Lint and Format Code Source: https://github.com/metaplex-foundation/mpl-core/blob/main/clients/js/CONTRIBUTING.md Apply automatic fixes for linting and code formatting issues. ```sh # Lint and/or format the client. pnpm lint:fix pnpm format:fix ``` -------------------------------- ### Code Generation - Never Edit Generated Files Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Highlights that files within `clients/js/src/generated/` are auto-generated and should not be manually edited. Changes should be made to the Rust program interfaces and then regenerated. ```bash # Never edit files in `clients/js/src/generated/` - they are auto-generated ``` -------------------------------- ### Fix Linting Issues Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Automatically fixes linting issues and formats code across the JavaScript client and Rust programs. ```bash pnpm lint:fix ``` -------------------------------- ### Stop Local Validator Source: https://github.com/metaplex-foundation/mpl-core/blob/main/CLAUDE.md Shuts down the running local Solana validator instance. ```bash pnpm validator:stop ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.