ERC-7578 · Final(最终) · ERC · 2023-08-01
ERC-7578: Physical Asset Redemption
一个 ERC-721 扩展,存储 NFT 背后实物的标准信息,如发行方、法定所有者、存放地点、条款、司法管辖区和申报价值,使持有者能够验证并赎回。
它解决什么问题?
NFT 越来越多地被用来代表实物:一瓶葡萄酒、一块手表、一根金条、一件存放在金库里的艺术品。但一个普通的 ERC-721 代币并不会说明这一主张由谁来背书。买家无法从代币看出是谁铸造的、谁在法律上拥有该物品、它存放在哪里,或者哪个合约管辖赎回。
ERC-7578 让每个代币都带有一组固定的披露字段,使持有者(或智能合约)可以立即评估交易对手、存放和法律风险,并知道赎回资产时该联系谁。
它如何运作
每个代币都有一个 Properties 结构,应当在铸造之前设置:
| 字段 | 含义 |
|---|---|
tokenIssuer |
铸造 NFT 的个人或实体 |
assetHolder |
实物资产的法定所有者(可能与发行方不同) |
storageLocation |
资产实际存放的地点 |
terms |
指向法律协议的链接;应为指向存储在 IPFS 上文档的 HTTP 链接 |
jurisdiction |
适用法律和司法管辖区 |
declaredValue |
铸造时的 Amount { currency, value };不一定是市场价值 |
合约公开:
getPropertiesOf(tokenId)— 返回该结构;不会 revert,对已销毁或未设置的代币返回空结构。PropertiesSet(tokenId, properties)— 设置属性时触发。PropertiesRemoved(tokenId)— 清除属性时触发。代币被销毁时,属性必须被删除。
参考实现拒绝铸造属性尚未事先初始化的代币。合约本身不验证数据:准确性由发行方负责。
示例代码
读取某个代币的披露信息(ethers v6):
import { Contract, JsonRpcProvider } from "ethers";
const abi = [
"function getPropertiesOf(uint256 tokenId) view returns (tuple(string tokenIssuer, string assetHolder, string storageLocation, string terms, string jurisdiction, tuple(string currency, uint256 value) declaredValue))",
];
const provider = new JsonRpcProvider(process.env.RPC_URL);
const nft = new Contract(collectionAddress, abi, provider);
const p = await nft.getPropertiesOf(42n);
console.log(p.tokenIssuer, p.assetHolder, p.storageLocation);
console.log("terms:", p.terms, "law:", p.jurisdiction);
console.log("declared:", p.declaredValue.value.toString(), p.declaredValue.currency);
在基于参考实现 ERC7578 的合约中带属性铸造:
function mint(address to, uint256 id, Properties calldata props) external onlyOwner {
_setPropertiesOf(id, props); // must happen before _safeMint
_safeMint(to, id);
}
需要注意
- 状态为 Final。
- 这些字段是自由格式的字符串。该标准披露信息;它并不证明物品存在,也不证明法律条款可以强制执行。
- 只有受信任且受访问控制的账户才应能够设置属性,规范还警告不要在之后允许未经授权的更改。
- 申报价值、货币格式或身份字符串是否有意义,完全取决于发行方,因此持有者仍应自行进行尽职调查。