OKRW.Mint (event)

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
검색어를 입력하세요