Open3

ERC-6551: Token Bound Accounts

Kosuke OgawaKosuke Ogawa
  • 既存のERC-721スマートコントラクトを変更することなく、トークンにアカウント(addressを持つ)を付与できる
  • アカウントの作成は、トークンごとにパーミッションレスレジストリを介して行われる(誰でも実行できる?
  • トークンに付与された各アカウントの制御は、ERC-721トークンの所有者に委任され、所有者はトークンに代わってオンチェーンアクションを実行できる


Kosuke OgawaKosuke Ogawa

アカウントやレジストリのインターフェース、実装例

```/// @dev the ERC-165 identifier for this interface is 0xeff4d378
interface IERC6551Account {
/// @dev Token bound accounts MUST implement a receive function.
///
/// Token bound accounts MAY perform arbitrary logic to restrict conditions
/// under which Ether can be received.
receive() external payable;

/// @dev Executes `call` on address `to`, with value `value` and calldata
/// `data`.
///
/// MUST revert and bubble up errors if call fails.
///
/// By default, token bound accounts MUST allow the owner of the ERC-721 token
/// which owns the account to execute arbitrary calls using `executeCall`.
///
/// Token bound accounts MAY implement additional authorization mechanisms
/// which limit the ability of the ERC-721 token holder to execute calls.
///
/// Token bound accounts MAY implement additional execution functions which
/// grant execution permissions to other non-owner accounts.
///
/// @return The result of the call
function executeCall(
    address to,
    uint256 value,
    bytes calldata data
) external payable returns (bytes memory);

/// @dev Returns identifier of the ERC-721 token which owns the
/// account
///
/// The return value of this function MUST be constant - it MUST NOT change
/// over time.
///
/// @return chainId The EIP-155 ID of the chain the ERC-721 token exists on
/// @return tokenContract The contract address of the ERC-721 token
/// @return tokenId The ID of the ERC-721 token
function token()
    external
    view
    returns (
        uint256 chainId,
        address tokenContract,
        uint256 tokenId
    );

/// @dev Returns the owner of the ERC-721 token which controls the account
/// if the token exists.
///
/// This is value is obtained by calling `ownerOf` on the ERC-721 contract.
///
/// @return Address of the owner of the ERC-721 token which owns the account
function owner() external view returns (address);

}

```interface IERC6551Registry {
    /// @dev Each registry MUST emit the AccountCreated event upon account creation
    event AccountCreated(
        address account,
        address implementation,
        uint256 chainId,
        address tokenContract,
        uint256 tokenId
    );

    /// @dev Creates a token bound account for an ERC-721 token.
    ///
    /// Emits AccountCreated event.
    ///
    /// @return the address of the created account
    function createAccount(
        address implementation,
        uint256 chainId,
        address tokenContract,
        uint256 tokenId
    ) external returns (address);

    /// @dev Returns the computed address of a token bound account
    ///
    /// @return The computed address of the account
    function account(
        address implementation,
        uint256 chainId,
        address tokenContract,
        uint256 tokenId
    ) external view returns (address);
}```

https://eips.ethereum.org/EIPS/eip-6551