Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create EIP-5298: ENS Trust to hold NFTs under ENS name #5300

Merged
merged 27 commits into from
Nov 15, 2022
Merged
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions EIPS/eip-5298.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
eip: 5298
title: ENS as Token Holder
description: An interface for holding tokens by ENS.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description is a bit vague, and is just a rewording of the title. Maybe choose a different word than "holding" here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so too, but didnt have a bette idea yet. Any suggestion? @SamWilsn

author: Zainan Victor Zhou (@xinbenlv)
discussions-to: https://ethereum-magicians.org/t/erc-eip-5198-ens-as-token-holder/10374
status: Draft
type: Standards Track
category: ERC
created: 2022-07-12
requires: 137, 721, 1155
---

## Abstract
An interface for smart contract to become a holder of tokens by honoring ENS ownership.
This specification supports [EIP-721](./eip-721.md) and [EIP-1155](./eip-1155.md) tokens and is expandable to future token standard or other standard.

## Motivation
Currently, if someone wants to receive a token, they have to set up a wallet address. By creating a smart contract that conforms to this interface specification, it is possible to decouple the transfer of ownership from the existence of wallet addresses.

## Specification

1. Any conforming smart contract must conform to `ERC721TokenReceiver` defined in [EIP-721](./eip-721.md) and `ERC1155TokenReceiver` defined in [EIP-1155](./eip-1155.md).

```solidity
interface IERC_ENS_AS_HOLDER is ERC721Receiver, ERC1155Receiver {
}
```

## Rationale
1. We choose ENS because it's a scoped ownership namespace.
This ERC shall also be able to work in other scoped ownership namespace approach.

## Backwards Compatibility
No backward compatibility issues were found.

## Reference Implementation
```solidity
contract ENSTokenHolding is ERC721TokenReceiver, Initializable {
address ENSRootRegistry _ensRoot;
mapping<address /* of ERC721 */ => tokenId=> string /* of owner*/)> _erc721TokenHolders;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line isn't valid solidity.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of this code would actually work 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it is just some peusdo code to help myself think. Still working in progress, let me remove it for now, cause it can be misleading for reader


function initializer(address ensRoot) {
_ensRoot = ensRoot;
}

function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes _data) external returns(bytes4) {
_erc721TokenHolders[_operator][_tokenId] = "0x" + msg.sender.toString();

return /*bytes4 comply to ERC721 onReceived*/
}

function setOwner(address erc721, uint256 tokenId, string ens) {
require(msg.sender.toString == "0x" + _erc721TokenHolders[erc721][tokenId]);
_erc721TokenHolders[erc721][tokenId] = newOwnerENS;
}

function claim(address erc721, uint256 tokenId) {
require(msg.sender.toString == "0x" + _erc721TokenHolders[erc721][tokenId]
|| _ensRoot.reverseLookup() == /*stored ens*);
ERC721 contract = ERC721(erc721);
erc721.safeTransferFrom(this, msg.sender, tokenId);
);
}
```

## Security Considerations
Needs discussion

## Copyright
Copyright and related rights waived via [CC0](../LICENSE.md).