mirror of
https://github.com/autistic-symposium/web3-starter-sol.git
synced 2025-05-01 22:36:03 -04:00
41 lines
1.3 KiB
Markdown
41 lines
1.3 KiB
Markdown
## ERC721
|
|
|
|
<br>
|
|
|
|
|
|
To see the difference between ERC20 and ERC721, look at the internal data structure used in ERC721:
|
|
|
|
|
|
```
|
|
mapping (uint256 => address) private deedOwner;
|
|
```
|
|
|
|
<br>
|
|
|
|
Whereas ERC20 tracks the balances that belong to each owner, with the owner being the primary key of the mapping,
|
|
ERC721 tracks each deed ID and who owns it, with the deed ID being the primary key of the mapping.
|
|
|
|
<br>
|
|
|
|
|
|
### The ERC721 contract interface specification
|
|
|
|
|
|
```
|
|
interface ERC721 /* is ERC165 */ {
|
|
event Transfer(address indexed _from, address indexed _to, uint256 _deedId);
|
|
event Approval(address indexed _owner, address indexed _approved,
|
|
uint256 _deedId);
|
|
event ApprovalForAll(address indexed _owner, address indexed _operator,
|
|
bool _approved);
|
|
|
|
function balanceOf(address _owner) external view returns (uint256 _balance);
|
|
function ownerOf(uint256 _deedId) external view returns (address _owner);
|
|
function transfer(address _to, uint256 _deedId) external payable;
|
|
function transferFrom(address _from, address _to, uint256 _deedId)
|
|
external payable;
|
|
function approve(address _approved, uint256 _deedId) external payable;
|
|
function setApprovalForAll(address _operator, boolean _approved) payable;
|
|
function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
|
}
|
|
```
|