इसे छोड़कर कंटेंट पर जाएं

अपनी साइट से मिंट करें

अपना EVM वॉलेट कनेक्टर और पब्लिक ABI इस्तेमाल करें। KurvDrop पर मिंटिंग एक ERC-20 ऑपरेशन है, payable ETH मिंट नहीं। ETH नेटवर्क गैस के लिए है। मुफ़्त मिंट फ़ेज़ में भी कलेक्शन की सर्विस फ़ीस लग सकती है, इसलिए लागत शून्य मानने की जगह कोट इस्तेमाल करें।

यह उदाहरण बिना ऑक्शन मॉड्यूल वाले पब्लिक फ़ेज़ को संभालता है और भुगतान को ठीक कोट जितना सीमित रखता है। यह विज़िटर का दिया ब्राउज़र वॉलेट इस्तेमाल करता है, कभी किसी सर्वर की प्राइवेट की नहीं। मंज़ूरी और मिंट लिखने से पहले खरीदार को कुल रकम, अतिरिक्त टोकन की लागत और चेन दिखाएं, और उनकी पुष्टि लें।

import {
createPublicClient, createWalletClient, custom, erc20Abi,
http, zeroAddress, zeroHash,
} from 'viem';
import { baseSepolia } from 'viem/chains';
const api = 'https://testnet.kurv.fun';
const { abi } = await fetch(`${api}/api/v1/contracts/kurvdrop`).then(r => r.json());
const publicClient = createPublicClient({ chain: baseSepolia, transport: http() });
const walletClient = createWalletClient({ chain: baseSepolia, transport: custom(window.ethereum) });
const [account] = await walletClient.requestAddresses();
await walletClient.switchChain({ id: baseSepolia.id });
// Woof Pack, verified in KURV's Base Sepolia catalog.
const address = '0x8354d02d8022f455db9acb235c6f6655c8adabd3';
const { collection: live } = await fetch(
`${api}/api/v1/collections/84532/${address}`
).then(r => r.json());
if (live.contract_type !== 'KurvDrop' || live.mint.active_phase_id === null) {
throw new Error('No public mint phase is available.');
}
const phaseId = BigInt(live.mint.active_phase_id);
const quantity = 1n;
const phase = await publicClient.readContract({ address, abi, functionName: 'getPhase', args: [phaseId] });
if (phase.module !== zeroAddress || phase.merkleRoot !== zeroHash) {
throw new Error('This example supports only public phases without an auction module.');
}
const paymentToken = await publicClient.readContract({ address, abi, functionName: 'paymentToken' });
const [maxTotalCost] = await publicClient.readContract({ address, abi, functionName: 'quoteMint', args: [phaseId, quantity] });
// Display these amounts using each token's on-chain decimals and symbol.
const required = new Map([[paymentToken.toLowerCase(), maxTotalCost]]);
if (phase.token !== zeroAddress && phase.tokenPrice > 0n) {
const token = phase.token.toLowerCase();
required.set(token, (required.get(token) ?? 0n) + phase.tokenPrice * quantity);
}
// Run only after the buyer reviews and confirms the displayed amounts.
for (const [token, amount] of required) {
const allowance = await publicClient.readContract({ address: token, abi: erc20Abi, functionName: 'allowance', args: [account, address] });
if (allowance >= amount) continue;
// Reset an existing allowance for tokens requiring zero before a new approval.
if (allowance > 0n) {
const reset = await walletClient.writeContract({ account, address: token, abi: erc20Abi, functionName: 'approve', args: [address, 0n] });
await publicClient.waitForTransactionReceipt({ hash: reset });
}
const approved = await walletClient.writeContract({ account, address: token, abi: erc20Abi, functionName: 'approve', args: [address, amount] });
await publicClient.waitForTransactionReceipt({ hash: approved });
}
// Exact quote ceiling: if the required price increased, simulation/mint refuses.
const { request } = await publicClient.simulateContract({
account, address, abi, functionName: 'mint',
args: [phaseId, quantity, 0n, [], maxTotalCost, zeroAddress],
});
const hash = await walletClient.writeContract(request);
const receipt = await publicClient.waitForTransactionReceipt({ hash });
if (receipt.status !== 'success') throw new Error('Mint did not complete.');

अलाउलिस्ट वाले फ़ेज़ के लिए, खरीदार के वॉलेट की अनुमत संख्या और Merkle proof, KURV के मौजूदा proof फ़्लो से लें और उन्हें मिंट के तीसरे और चौथे आर्गुमेंट के रूप में भेजें। प्राइवेट फ़ेज़ में खाली proof कभी न डालें। वॉलेट की सीमा, फ़ेज़ की सप्लाई, रोक, ऑक्शन के लिए रोके गए NFT और कुल लागत, सब कॉन्ट्रैक्ट लागू करता है; भेजने से पहले सिमुलेशन सफल होना चाहिए। घटती कीमत वाले ऑक्शन और एक-एक NFT के ऑक्शन अपने बिक्री मॉड्यूल इस्तेमाल करते हैं और साधारण इनलाइन mint फ़ेज़ नहीं हैं; जब तक आप उस मॉड्यूल का ABI और सेटलमेंट फ़्लो इंटीग्रेट और जांच न लें, आधिकारिक पेज इस्तेमाल करें।

मिंट का आखिरी आर्गुमेंट एक रेफ़रर वॉलेट पता है, कोई ट्रैकिंग स्ट्रिंग नहीं। जब तक आप जानबूझकर डिप्लॉय हुए कलेक्शन की रेफ़रल शर्तें इंटीग्रेट न करें, डिफ़ॉल्ट रूप से zeroAddress रखें। फ़ीस का असली बंटवारा कॉन्ट्रैक्ट तय करता है; लिंक कोड जोड़ने से अपने आप कोई कमीशन नहीं बनता। मार्केटप्लेस पर दोबारा बिक्री मार्केटप्लेस कॉन्ट्रैक्ट और साइन किए ऑर्डर इस्तेमाल करती है, यहां दिखाया गया पहले मिंट वाला कॉल नहीं।

कलेक्शन के जवाब का स्कीमा पब्लिक API में देखें। तैयार विजेट के लिए कलेक्शन एम्बेड इस्तेमाल करें। कॉन्ट्रैक्ट की अनुमतियां, फ़ीस और कलेक्शन की मूल शर्तें फिर भी लागू होती हैं; देखें फ़ीस और जोखिम और अस्वीकरण।

यहाँ लिखी कोई भी बात वित्तीय सलाह नहीं है। मिंट करने, खरीदने या वापस बेचने से पहले जोखिम और अस्वीकरण पढ़ें। kurv.fun पर वापस जाएँ। गोपनीयता नीति। उपयोग की शर्तें। ।