KIP7

KIP 문서

클레이튼에서 대체 가능한 토큰(Fungible Token)의 표준이다. ERC-20에서 파생되었으며 차이점은 다음과 같다.

KIP-7 과 ERC-20 차이점

  • 보다 많은 선택 가능한 기능들을 (mint, burn and pause extension) 지원
  • 모든 토큰의 transfer/mint/burn 은 이벤트 로그를 남겨야 한다. 이는 즉 Transfer 이벤트가 transfer/mint/burn 시 반드시 찍혀야 함을 의미한다.
  • 지원하는 method group에 대한 KIP-13 를 구현해야 한다.
  • safeTransfer로 컨트랙트에게 토큰을 보낼 시 리시브 훅을 호출한다.
/// @title KIP-7 Fungible Token Standard, optional wallet interface
/// @dev Note: the KIP-13 identifier for this interface is 0x9d188c22.
interface IKIP7TokenReceiver {
/// @notice Handle the receipt of KIP-7 token
/// @dev The KIP-7 smart contract calls this function on the recipient
///  after a `safeTransfer`. This function MAY throw to revert and reject the
///  transfer. Return of other than the magic value MUST result in the
///  transaction being reverted.
///  Note: the contract address is always the message sender.
/// @param _operator The address which called `safeTransferFrom` function
/// @param _from The address which previously owned the token
/// @param _amount The token amount which is being transferred.
/// @param _data Additional data with no specified format
/// @return `bytes4(keccak256("onKIP7Received(address,address,uint256,bytes)"))`
///  unless throwing
function onKIP7Received(address _operator, address _from, uint256 _amount, bytes _data) external returns(bytes4);
}

MUST

  • 모든 토큰의 transfer/mint/burn 은 이벤트 로그를 남겨야 한다. 이는 즉 Transfer 이벤트가 transfer/mint/burn 시 반드시 찍혀야 함을 의미한다.
  • 지원하는 인터페이스를 반드시 kip13 로 알려야 한다.
  • 컨트랙트가 safeTransfer 로 토큰을 받을 수 있으려면 반드시 리시브 훅(onKIP7Received)을 구현해야 한다. 리시브 훅은 반드시 0x9d188c22 magic value를 리턴해야 한다.

tags: blockchain, defi, smart contract, erc20, klaytn