Mint From Metaplex Candy Machine
Metaplex is a powerful NFT framework built on Solana, designed to simplify the creation, management, and trading of non-fungible tokens…
Mint From Metaplex Candy Machine

Solana Metaplex Candy Machine
Metaplex is a powerful NFT framework built on Solana, designed to simplify the creation, management, and trading of non-fungible tokens. One key feature of Metaplex is the ability to create and manage candy machines, which are automated market makers for NFTs. In this article, we will walk through the process of minting NFTs from a candy machine using the Metaplex JavaScript library.
Prerequisites Before we begin, you will need to have a few things set up:
-
A Solana wallet: You will need a Solana wallet to sign transactions on the Solana blockchain. You can create a new wallet or use an existing one.
-
The Metaplex JavaScript library: You will need to install and import the Metaplex JavaScript library in your JavaScript development environment.
npm install @metaplex/js
const { Connection, clusterApiUrl } = require('@solana/web3.js');
const { Metaplex } = require('@metaplex/js');
const connection = new Connection(clusterApiUrl('devnet'));
const metaplex = new Metaplex(connection);
Minting from a Candy Machine To mint NFTs from a candy machine using Metaplex, you will need to perform the following steps:
- Retrieve the candy machine information: Before you can mint NFTs, you will need to retrieve the information about the candy machine. You can use the
Metaplex.getCandyMachinefunction to retrieve the candy machine object.
const candyMachineAddress = new PublicKey('candy_machine_address');
const candyMachine = await metaplex.getCandyMachine(candyMachineAddress);
In this example, we are retrieving the candy machine object using its public key.
- Check if the candy machine is ready: Before you can mint NFTs, you need to check if the candy machine is ready. You can use the
candyMachine.isReadyfunction to check if the candy machine is ready.
if (!candyMachine.isReady) {
throw new Error('Candy machine not ready');
}
In this example, we are checking if the candy machine is ready before proceeding with the minting process.
- Generate a token account: Before you can mint NFTs, you will need to create a token account to receive the NFTs. You can create a new token account using the
Token.createAccountfunction provided by the Solana Web3.js library.
const { Token, TOKEN_PROGRAM_ID } = require('@solana/spl-token');
const mintPublicKey = new PublicKey('mint_account_address');
const recipientAccount = new Account();
const tokenAccount = await Token.createAccount(
connection,
mintPublicKey,
recipientAccount.publicKey,
wallet.publicKey,
);
In this example, we are creating a new token account associated with the NFT mint account using the Token.createAccount function. We also create a new recipient account using the Account constructor provided by the Solana Web3.js library.
- Mint the NFT: Once you have retrieved the candy machine object and created a token account, you can mint NFTs using the
candyMachine.mintOneTokenfunction.
await candyMachine.mintOneToken(recipientAccount.publicKey, {
amount: 1,
currency: tokenAccount,
});
In this example, we are minting one NFT using the candyMachine.mintOneToken function. We specify the recipient account, the number of NFTs to mint, and the token account to receive the payment.
메타데이터
- post_id
- e079bd89f73c
- slug
- mint-from-metaplex-candy-machine-e079bd89f73c
- url
- https://medium.com/@freyja__3991/mint-from-metaplex-candy-machine-e079bd89f73c
- canonical_url
- https://medium.com/@freyja__3991/mint-from-metaplex-candy-machine-e079bd89f73c
- author_url
- https://medium.com/@freyja__3991
- status
- ok
- fetched_at
- 2026-09-04 22:10:31