Skip to main content

Getting Started

info

A newer version of this page is available in the Developer Hub. Click here to read it.

This page aims to help you get started with Candy Machines by listing all relevant libraries that interact with them.

JavaScript​

If you are developing for the web or using Node.js, then we have a few libraries at your disposal.

Metaplex provides a Umi-compatible library that can be used to interact with Candy Machines. Thanks to the Umi framework, it ships without any opinionated dependencies and, thus, provides a lightweight library that can be used in any JavaScript project.

To get started, you'll need to install the Umi framework and the Umi-compatible Candy Machine library β€” which is currently under the alpha tag.

npm install \
@metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults \
@solana/web3.js \
@metaplex-foundation/mpl-candy-machine@alpha

Next, you may create your Umi instance and install the mplCandyMachine plugin like so.

import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { mplCandyMachine } from "@metaplex-foundation/mpl-candy-machine";

// Use the RPC endpoint of your choice.
const umi = createUmi("http://127.0.0.1:8899").use(mplCandyMachine());

That's it, you can now interact with Candy Machines by using the various functions provided by the library and passing your Umi instance to them. Here's an example of fetching a candy machine account and its associated candy guard account.

import { publicKey } from "@metaplex-foundation/umi";
import {
fetchCandyMachine,
fetchCandyGuard,
} from "@metaplex-foundation/mpl-candy-machine";

const candyMachinePublicKey = publicKey("...");
const candyMachine = await fetchCandyMachine(umi, candyMachinePublicKey);
const candyGuard = await fetchCandyGuard(umi, candyMachine.mintAuthority);

πŸ”— Helpful Links:

Solita library​

Before releasing the Umi framework, we provided program-specific libraries generated by Solita which are still available for you to use. Since candy machines are composed of two programs, you will need to install two libraries.

JS SDK​

Before releasing the Umi framework, we provided a monolithic JavaScript SDK that encapsulated the Solita library into one big heavy API. This SDK is still available for you to use but we now recommend using the Umi library instead. Also, note that the JS SDK does not support minting Programmable NFTs.

Once the JS SDK is installed, you can access its Candy Machine module via metaplex.candyMachines(). It is composed of several methods that focus on real use cases to make our life easier. Here are some of them.

metaplex.candyMachines().create();
metaplex.candyMachines().update();
metaplex.candyMachines().insertItems();
metaplex.candyMachines().delete();
metaplex.candyMachines().mint();
metaplex.candyMachines().findByAddress();
metaplex.candyMachines().callGuardRoute();

πŸ”— Helpful Links:

Rust​

If you are developing in Rust, you can also use the Rust crates to interact with Metaplex’s programs. Since our programs are written in Rust, these crates should contain everything you need to parse accounts and build instructions.

This can be helpful when developing Rust clients but also when making CPI calls to Metaplex programs within your own program.

Swift​

Coming soon.

Kotlin​

Coming soon.