testnet
GitHub EN

이벤트: Mint

event Mint(address indexed minter, address indexed recipient, uint256 amount)

mint 함수가 성공적으로 호출될 때 OKRW 프리컴파일에 의해 발생합니다. 이 이벤트는 EVM에서 비롯된 모든 OKRW 발행 활동에 대한 검증 가능하고 온체인에 기록된 증거를 제공합니다. 인덱서와 클라이언트 애플리케이션은 이 이벤트를 구독하여 OKRW 공급 및 분배를 추적할 수 있습니다.

파라미터

이름 타입 필수 설명
minter address - 발행 호출을 시작한 공인된 주소입니다.
recipient address - 새로 발행된 토큰을 받은 주소입니다.
amount uint256 - 발행된 OKRW의 양입니다.

반환값

타입:

예제

Ethers.js로 Mint 이벤트 수신하기

이 스크립트는 WebSocket 프로바이더를 사용하여 `Mint` 이벤트를 실시간으로 구독하는 방법을 보여주며, 백엔드 서비스나 프론트엔드가 새로운 토큰 생성에 즉시 반응할 수 있도록 합니다.

const { ethers } = require("ethers");

const okrwPrecompileAddress = "0x1000000000000000000000000000000000000001";
const okrwAbi = [
    "event Mint(address indexed minter, address indexed recipient, uint256 amount)"
];

// Assume 'provider' is a connected ethers.Provider
const okrwContract = new ethers.Contract(okrwPrecompileAddress, okrwAbi, provider);

console.log("Listening for new OKRW mints...");

okrwContract.on("Mint", (minter, recipient, amount, event) => {
    console.log("--- New Mint Detected ---");
    console.log(`  Minter: ${minter}`);
    console.log(`  Recipient: ${recipient}`);
    console.log(`  Amount: ${ethers.formatEther(amount)} OKRW`);
    console.log(`  Transaction: ${event.log.transactionHash}`);
});
ESC
검색어를 입력하세요