Skip to main content

Sol Payment

info

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

Overview

The Sol Payment guard allows us to charge the payer an amount in SOL when minting. Both the amount of SOL and the destination address can be configured.

CandyMachinesV3-GuardsSolPayment.png

Guard Settings

The Sol Payment guard contains the following settings:

  • Lamports: The amount in SOL (or lamports) to charge the payer.
  • Destination: The address of the wallet that should receive all payments related to this guard.

JavaScript — Umi library (recommended)

Here’s how we can set up a Candy Machine using the Sol Payment guard. Note that, in this example, we’re using the current identity as the destination wallet.

create(umi, {
// ...
guards: {
solPayment: some({
lamports: sol(1.5),
destination: umi.identity.publicKey,
}),
},
});

API References: create, SolPayment

JavaScript — SDK

Here’s how we can create a Candy Machine using the Sol Payment guard via the JS SDK. Note that, in this example, we’re using the current identity as the destination wallet.

import { sol } from "@metaplex-foundation/js";

const { candyMachine } = await metaplex.candyMachines().create({
// ...
guards: {
solPayment: {
amount: sol(1.5),
destination: metaplex.identity().publicKey,
},
},
});

API References: Operation, Input, Output, Transaction Builder, Guard Settings.

Mint Settings

The Sol Payment guard contains the following Mint Settings:

  • Destination: The address of the wallet that should receive all payments related to this guard.

Note that, if you’re planning on constructing instructions without the help of our SDKs, you will need to provide these Mint Settings and more as a combination of instruction arguments and remaining accounts. See the Candy Guard’s program documentation for more details.

JavaScript — Umi library (recommended)

You may pass the Mint Settings of the Sol Payment guard using the mintArgs argument like so.

mintV2(umi, {
// ...
mintArgs: {
solPayment: some({ destination: treasury }),
},
});

API References: mintV2, SolPaymentMintArgs

JavaScript — SDK

The JS SDK does not require any Mint Settings for the Sol Payment guard since it can infer them from the provided Candy Machine model.

Route Instruction

The Sol Payment guard does not support the route instruction.