Skip to content

Commit

Permalink
Docs: Add ERC4907A docs (#380)
Browse files Browse the repository at this point in the history
* Add ERC4907 docs

* Add note on retaining user info upon transfer

* Nits
  • Loading branch information
Vectorized authored Jul 18, 2022
1 parent afdf09a commit 5e70c80
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 0 deletions.
77 changes: 77 additions & 0 deletions docs/erc4907a.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# ERC4907A

[`erc721a/contracts/extensions/ERC4907A.sol`](https://github.com/chiru-labs/ERC721A/blob/main/contracts/extensions/ERC4907A.sol)

[ERC4907](https://eips.ethereum.org/EIPS/eip-4907) compliant extension of ERC721A, which allows owners and authorized addresses to add a time-limited role with restricted permissions to ERC721 tokens.

This implementation does **not** reset the user information upon token transfer.
The new owner must call [`setUser`](#setUser) to change or reset the user.

To reset or alter the user information after each transfer, you will need to override either
[`_beforeTokenTransfers`](erc721a.md#_beforeTokenTransfers) or
[`_afterTokenTransfers`](erc721a.md#_afterTokenTransfers) in ERC721A.

Inherits:

- [ERC721A](erc721a.md)
- [IERC4907A](interfaces.md#ierc4907a)


## Functions

### setUser

```solidity
function setUser(uint256 tokenId, address user, uint64 expires) public virtual
```

Sets the `user` and `expires` for `tokenId`.

The zero address indicates there is no user.

Requirements:

- The caller must own `tokenId` or be an approved operator.


### userOf

```solidity
function userOf(uint256 tokenId) public view virtual returns (address)
```

Returns the user address for `tokenId`.

The zero address indicates that there is no user or if the user is expired.

### userExpires

```solidity
function userExpires(uint256 tokenId) public view virtual returns (uint256)
```

Returns the user's expires of `tokenId`.

### \_explicitUserOf

```solidity
function _explicitUserOf(uint256 tokenId) internal view virtual returns (address)
```

Returns the user address for `tokenId`, ignoring the expiry status.


## Events

### UpdateUser

`IERC4907-UpdateUser`

```solidity
event UpdateUser(uint256 indexed tokenId, address indexed user, uint64 expires)
```

Emitted when the `user` of an NFT or the `expires` of the `user` is changed.

The zero address for user indicates that there is no user address.

52 changes: 52 additions & 0 deletions docs/erc721a.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,58 @@ If set, the resulting URI for each token will be the concatenation of the `baseU
Empty by default, it can be overridden in child contracts.


### \_beforeTokenTransfers

```solidity
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual
```

Hook that is called before a set of serially-ordered token IDs are about to be transferred. This includes minting.

Also called before burning one token.

`startTokenId` - the first token ID to be transferred.
`quantity` - the amount to be transferred.

Calling conditions:

- When `from` and `to` are both non-zero, `from`'s `tokenId` will be transferred to `to`.
- When `from` is zero, `tokenId` will be minted for `to`.
- When `to` is zero, `tokenId` will be burned by `from`.
- `from` and `to` are never both zero.


### \_afterTokenTransfers

```solidity
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual
```

Hook that is called after a set of serially-ordered token IDs are about to be transferred. This includes minting.

Also called after burning one token.

`startTokenId` - the first token ID to be transferred.
`quantity` - the amount to be transferred.

Calling conditions:

- When `from` and `to` are both non-zero, `from`'s `tokenId` will be transferred to `to`.
- When `from` is zero, `tokenId` will be minted for `to`.
- When `to` is zero, `tokenId` will be burned by `from`.
- `from` and `to` are never both zero.


### \_toString

```solidity
Expand Down
13 changes: 13 additions & 0 deletions docs/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,16 @@ Inherits:
import 'erc721a/contracts/interfaces/IERC721AQueryable.sol';
```

### IERC4907A

[`erc721a/contracts/extensions/IERC4907A.sol`](https://github.com/chiru-labs/ERC721A/blob/main/contracts/extensions/IERC4907A.sol)

Inherits:

- [IERC721A](#ierc721a)

```solidity
import 'erc721a/contracts/interfaces/IERC4907A.sol';
```
1 change: 1 addition & 0 deletions docs/sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [ERC721A](erc721a.md)
- [ERC721ABurnable](erc721a-burnable.md)
- [ERC721AQueryable](erc721a-queryable.md)
- [ERC4907A](erc4907a.md)
- [Interfaces](interfaces.md)
- **Theme**
<div id="theme">
Expand Down

0 comments on commit 5e70c80

Please sign in to comment.