Erc 6551

- 1 min

ERC-6551

token bound account 是一种与特定非同质化代币(NFT)绑定的智能合约账户。它允许NFT拥有资产并与应用程序进行交互,赋予NFT像以太坊用户一样的功能,包括自我保管资产、执行任意操作、控制多个独立账户以及在多个链上使用账户。每个token bound account通过一个单例注册表创建,确保每个NFT都有唯一且可预测的智能合约账户地址。这种机制使得NFT能够更有效地代表复杂的现实资产。

graph TD
    A[NFT] -->|Owns| B[Token Bound Account]
    B -->|Interacts with| C[Registry]
    C -->|Creates| B 
    B -->|Implements| D[IERC6551Account]
    B -->|Implements| E[IERC6551Executable]
    F[User] -->|Holds| A 
    G[Smart Contract] -->|Interacts with| B 
    C -->|Calculates| H[Account Address]
    H -->|Based on| I[Implementation Address]
    H -->|Based on| J[Token Contract Address]
    H -->|Based on| K[Token ID]
    H -->|Based on| L[Chain ID]
    M[ERC-721] -->|Standard for| A 
    N[ERC-165] -->|Interface Detection| D 
    O[ERC-1271] -->|Signature Validation| D 
    style A fill:#f9f,stroke:#333,stroke-width:2px;
    style B fill:#bbf,stroke:#333,stroke-width:2px;
    style C fill:#ffb,stroke:#333,stroke-width:2px;
    style D fill:#bfb,stroke:#333,stroke-width:2px;
    style E fill:#bfb,stroke:#333,stroke-width:2px;
    style F fill:#ff0,stroke:#333,stroke-width:2px;
    style G fill:#0ff,stroke:#333,stroke-width:2px;
    style H fill:#fbb,stroke:#333,stroke-width:2px;
    style I fill:#fbb,stroke:#333,stroke-width:2px;
    style J fill:#fbb,stroke:#333,stroke-width:2px;
    style K fill:#fbb,stroke:#333,stroke-width:2px;
    style L fill:#fbb,stroke:#333,stroke-width:2px;
    style M fill:#ff0,stroke:#333,stroke-width:2px;
    style N fill:#ff0,stroke:#333,stroke-width:2px;
    style O fill:#ff0,stroke:#333,stroke-width:2px;

createAccount 函数中

  1. tokenContract: ERC-721地址

  2. implementation: -这是一个地址,指向实现代币绑定账户功能的智能合约。它必须符合 IERC6551Account 接口,定义了代币绑定账户的行为和功能。 -该地址用于指定在创建代币绑定账户时所使用的具体合约实现。

总结来说,tokenContract 是与特定 NFT相关的合约地址,而 implementation 是用于创建和管理代币绑定账户的合约实现地址。两者在功能和用途上是不同的。



sequenceDiagram
  participant line_1 as user
  participant line_2 as 注册表(无权限,跨链)
  line_1 ->> line_2: create account(chainId,tokenContract,tokenId)
  line_2 ->> line_2: emit ERC6551AccountCreated