콘텐츠로 이동

내 사이트에서 민팅하기

내 EVM 지갑 커넥터와 공개 ABI를 쓰세요. KurvDrop 민팅은 ETH를 지불하는 payable 민팅이 아니라 ERC-20 작업이에요. ETH는 네트워크 가스비에 쓰여요. 무료 민팅 단계에도 컬렉션의 서비스 수수료가 붙을 수 있으니, 비용이 0이라고 가정하지 말고 시세를 쓰세요.

이 예시는 경매 모듈이 없는 공개 단계를 다루고, 결제 상한을 정확한 시세로 정해요. 서버 개인 키가 아니라 방문자가 제공하는 브라우저 지갑을 써요. 승인과 민팅 쓰기를 실행하기 전에 구매자에게 합계, 추가 토큰 비용, 체인을 보여 주고 확인을 받으세요.

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.');

허용 목록 단계라면, KURV의 기존 증명 흐름에서 구매자 지갑의 허용 수량과 Merkle 증명을 받아 민팅의 세 번째와 네 번째 인자로 넘기세요. 비공개 단계에 빈 증명을 대신 넣지 마세요. 지갑 한도, 단계 공급량, 일시 중지, 경매 보류, 총비용은 컨트랙트가 강제해요. 보내기 전에 시뮬레이션이 성공해야 해요. 가격이 내려가는 경매와 작품 경매는 자체 판매 모듈을 쓰고, 일반적인 인라인 mint 단계가 아니에요. 그 모듈의 ABI와 정산 흐름을 연동하고 검증하기 전까지는 공식 페이지를 쓰세요.

마지막 민팅 인자는 추적용 문자열이 아니라 추천인 지갑 주소예요. 배포된 컬렉션의 추천 조건을 의도적으로 연동하기 전까지는 기본값으로 zeroAddress를 쓰세요. 실제 수수료 분배는 컨트랙트가 정해요. 링크 코드를 붙인다고 그것만으로 수수료가 생기지는 않아요. 마켓플레이스 재판매는 여기 보이는 1차 민팅 호출이 아니라, 마켓플레이스 컨트랙트와 서명된 주문을 써요.

컬렉션 응답 스키마는 공개 API를 참고하세요. 바로 쓸 수 있는 위젯은 컬렉션 임베드를 쓰세요. 컨트랙트 권한, 수수료, 그리고 해당 컬렉션의 조건은 여전히 적용돼요. 수수료와 리스크 및 면책 조항을 참고하세요.

이곳의 어떤 내용도 투자 조언이 아니에요. 민팅하거나 사거나 되팔기 전에 리스크 및 면책 조항 문서를 꼭 읽어 주세요. kurv.fun으로 돌아가기. 개인정보처리방침. 이용약관. .