ERC-5192 · Final(확정) · ERC · 2022-07-01
ERC-5192: Minimal Soulbound NFTs
가장 작은 소울바운드 토큰 표준. `locked(tokenId)` 플래그를 가진 ERC-721 확장으로, 지갑과 마켓플레이스가 토큰을 전송할 수 없음을 감지할 수 있게 한다.
어떤 문제를 해결하나요?
자격 증명, 출석 배지, 업적, 멤버십, 평판처럼 절대 주인이 바뀌어서는 안 되는 토큰이 있습니다. 이런 "소울바운드" 토큰(World of Warcraft의 거래 불가 아이템에서 따온 이름)은 전송 시 그냥 revert하는 일반 ERC-721 컨트랙트로 만들어져 왔습니다.
온체인에서는 그렇게 동작하지만, 지갑이나 마켓플레이스는 이를 미리 알 방법이 없습니다. "전송"이나 "판매 등록" 버튼을 보여 주고, 사용자가 시도하면 트랜잭션이 실패합니다. 프로젝트마다 전송 불가를 나타내는 방식도 달랐습니다.
ERC-5192는 도구가 소울바운드 토큰을 미리 인식할 수 있도록 최소한의 감지 가능한 플래그를 추가합니다.
어떻게 동작하나요?
인터페이스에는 함수 하나와 이벤트 두 개가 있습니다.
interface IERC5192 {
event Locked(uint256 tokenId);
event Unlocked(uint256 tokenId);
function locked(uint256 tokenId) external view returns (bool);
}
locked(tokenId)가true를 반환하면, 그 토큰을 전송할 수 있는 모든 ERC-721 함수는 revert 해야 합니다.- 상태가 바뀔 때
Locked/Unlocked가 emit되며, 민팅 시에도 초기 상태를 알리기 위해 emit됩니다. - 제로 주소가 소유한 토큰(즉 존재하지 않는 토큰)을 조회하면 revert해야 합니다.
- 컨트랙트는
supportsInterface(0xb45a3c0e)(ERC-165)에 대해true를 반환해야 합니다.
잠금은 토큰별이므로 한 컨트랙트에 전송 가능한 토큰과 불가능한 토큰을 섞거나, 나중에 토큰의 잠금을 해제할 수 있습니다.
샘플 코드
OpenZeppelin v5를 사용한 간단한 소울바운드 배지:
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
interface IERC5192 {
event Locked(uint256 tokenId);
event Unlocked(uint256 tokenId);
function locked(uint256 tokenId) external view returns (bool);
}
contract Badge is ERC721, Ownable, IERC5192 {
constructor() ERC721("Badge", "BDG") Ownable(msg.sender) {}
function mint(address to, uint256 tokenId) external onlyOwner {
_safeMint(to, tokenId);
emit Locked(tokenId);
}
function locked(uint256 tokenId) external view returns (bool) {
_requireOwned(tokenId); // reverts for nonexistent tokens
return true;
}
// Allow mint (from == 0) and burn (to == 0); block everything else.
function _update(address to, uint256 tokenId, address auth) internal override returns (address) {
address from = _ownerOf(tokenId);
require(from == address(0) || to == address(0), "soulbound");
return super._update(to, tokenId, auth);
}
function supportsInterface(bytes4 id) public view override returns (bool) {
return id == 0xb45a3c0e || super.supportsInterface(id);
}
}
프런트엔드에서 확인하기(ethers v6):
const isSBT = await nft.supportsInterface("0xb45a3c0e");
const isLocked = isSBT && (await nft.locked(tokenId));
알아둘 점
- 상태: Final.
- "Locked"는 전송이 revert된다는 뜻입니다. 보유자가 토큰을 소각(burn)할 수 있는지, 누가 잠금을 해제할 수 있는지는 말하지 않으며, 이는 각 컨트랙트에 달려 있습니다.
- 표준은 전송 함수가 revert해야 한다고만 요구합니다.
approve에 대해서는 아무 말도 하지 않으며, 잠긴 토큰에서는 무해하지만 쓸모가 없습니다. - 관련 접근 방식들은 더 많은 구조를 더합니다. ERC-5484(소각 권한이 있는 합의형 소울바운드 토큰), ERC-4973(계정 바운드 토큰), ERC-5114(다른 NFT에 묶인 소울바운드 배지)입니다.