# MBA Factory & Implementation

The reference implementation of an MBA factory contract is available at <https://eips.ethereum.org/EIPS/eip-6551#registry>.

## **Account Interface**

The MBA implementation should follow the rules as described below:

* All token bound accounts SHOULD be created via the singleton registry;
* All token bound account implementations MUST implement ERC-165 interface detection;
* All token bound account implementations MUST implement ERC-1271 signature validation.
* All token bound account implementations MUST implement the following interface.

```solidity
/// @dev the ERC-165 identifier for this interface is `0x6faff5f1`
interface IERC6551Account {
     /**
      * @dev Allows the account to receive Ether.
      *
      * Accounts MUST implement a `receive` function.
      *
      * Accounts MAY perform arbitrary logic to restrict conditions
      * under which Ether can be received.
      */
     receive() external payable;
     /**
      * @dev Returns the identifier of the non-fungible token which owns the account.
      *
      * The return value of this function MUST be constant - it MUST NOT change over time.
      *
      * @return chainId       The chain ID of the chain the token exists on
      * @return tokenContract The contract address of the token
      * @return tokenId       The ID of the token
      */
     function token() external view returns (uint256 chainId, address tokenContract, uint256 tokenId);
     /**
      * @dev Returns a value that SHOULD be modified each time the account changes state.
      *
      * @return The current account state
      */
     function state() external view returns (uint256);
     /**
      * @dev Returns a magic value indicating whether a given signer is authorized to act on behalf
      * of the account.
      *
      * MUST return the bytes4 magic value 0x523e3260 if the given signer is valid.
      *
      * By default, the holder of the non-fungible token the account is bound to MUST be considered
      * a valid signer.
      *
      * Accounts MAY implement additional authorization logic which invalidates the holder as a
      * signer or grants signing permissions to other non-holder accounts.
      *
      * @param  signer     The address to check signing authorization for
      * @param  context    Additional data used to determine whether the signer is valid
      * @return magicValue Magic value indicating whether the signer is valid
      */
     function isValidSigner(address signer, bytes calldata context)
         external
         view
         returns (bytes4 magicValue);
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.iotex.io/ioid/technical-specification/mba-factory-and-implementation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
