You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Solana Metaplex与Candy Machine实现NFT铸币资金多钱包拆分问题

How to Split Mint Funds Across Multiple Wallets with Metaplex Candy Machine

Hey there! I see you've got secondary sales royalties split working perfectly via the creators array in your NFT metadata, but you're stuck on splitting initial mint funds instead of having them all funnel to the single treasury wallet. Let's break down why this happens and how to fix it.

Why the creators array doesn't handle mint funds

First, a quick clarity check: The creators field in your metadata only controls secondary sale royalties (the 5% you set with seller_fee_basis_points). By default, Metaplex's Candy Machine sends all initial mint SOL directly to the treasury wallet you configured during setup—this logic is hardcoded into the default Candy Machine core contract, and it doesn't reference the metadata's creators for mint payments.

Solutions to split mint funds

1. Modify the Candy Machine Core Contract (Most Reliable)

To split mint funds at the exact moment of minting, you'll need to tweak the Candy Machine's smart contract to distribute payments to your creators instead of sending everything to one treasury. Here's how to approach this:

  • Navigate to the candy-machine-core contract in your Metaplex repo.
  • Find the mint function (usually in src/processor.rs or similar) where the minter's SOL gets transferred to the treasury.
  • Replace the single treasury transfer with logic that calculates each creator's share and sends funds to their addresses.

Here's a simplified example of what that code might look like (for SOL payments):

use solana_program::{system_instruction::transfer, program::invoke};

// Inside the mint processor logic
let total_mint_amount = msg.value; // Amount the minter paid in lamports
let creators = &candy_machine.data.creators; // Pull creators from your Candy Machine config

for creator in creators {
    // Calculate the share amount (ensure shares add up to 100)
    let share_amount = total_mint_amount * creator.share as u64 / 100;
    if share_amount > 0 {
        // Create a transfer instruction for this creator's share
        let transfer_ix = transfer(
            &payer.key(),
            &creator.address,
            share_amount,
        );
        // Execute the transfer
        invoke(
            &transfer_ix,
            &[
                payer.to_account_info(),
                creator.address.to_account_info(),
                system_program.to_account_info(),
            ],
        )?;
    }
}

Note: You'll need to add creator share data to your Candy Machine config (or pull it directly from the NFT metadata during mint). Double-check that shares sum to 100 to avoid leftover funds.

After modifying the contract, redeploy it to your target network (testnet/mainnet) and update your Candy Machine setup to use this custom contract address instead of the default one.

2. Use a Middle Wallet + Automation Script (No Contract Changes)

If you don't want to modify and redeploy the contract, use a middle treasury wallet with automated splitting:

  • Configure your Candy Machine to send all mint funds to this middle wallet instead of your final treasury.
  • Write a script (using TypeScript + @solana/web3.js or Python + solana-py) that listens for incoming transactions to the middle wallet.
  • When a mint payment is detected, calculate each creator's share and send the corresponding SOL to their wallets.

For reliability, host this script on a server or use a chain automation tool like Clockwork to trigger splitting automatically whenever funds arrive.

Key Notes

  • Always test any changes on a testnet first to avoid losing real funds.
  • Remember SOL is denominated in lamports (1 SOL = 1,000,000,000 lamports) to avoid precision errors when calculating shares.
  • If using the custom contract approach, update your Candy Machine CLI commands to point to your deployed contract address.

内容的提问来源于stack exchange,提问作者Abdulmoiz Ahmer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 22:42:36