Blockchain
為什麼我的代幣被歸類為 ERC721 而不是 ERC20?
我使用 ERC20Interface 創建了一個 ERC20 令牌,但它在 Mumbai 多邊形掃描中被歸類為 ERC721。可能是什麼原因?
interface IERC20 { function totalSupply() external view returns (uint256); function decimals() external view returns (uint8); function symbol() external view returns (string memory); function name() external view returns (string memory); function getOwner() external view returns (address); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address _owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 indexed value); event Approval(address indexed owner, address indexed spender, uint256 indexed value); } contract MyToken is IERC20 { mapping (address => mapping (address => uint256)) private _allowances; mapping (address => uint256) internal _balances; uint256 public _totalSupply; uint8 public _decimals; string public _symbol; string public _name; address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() { owner = msg.sender; _name = "MyToken"; _symbol = "MTK"; _decimals = 0; _totalSupply = 1000000; _balances[owner] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); }
謝謝
原因是事件
Transfer
有數量索引。這是 ERC721 的模式,而不是 ERC20。考慮改變:
event Transfer(address indexed from, address indexed to, uint256 indexed value);
至:
event Transfer(address indexed from, address indexed to, uint256 value);
對於
Approval
.