IPAccountImpl
The IPAccountImpl contract is Story’s implementation of the IP Account, which follows the ERC-6551 standard for token-bound accounts. It provides functionality for IP assets to own and manage other assets, execute transactions, and interact with other contracts in a permissioned manner.
State Variables
ACCESS_CONTROLLER
The address of the AccessController contract used for permission checks. This is immutable and set during construction.
Inheritance
IPAccountImpl inherits from:
- ERC6551: Base implementation of the ERC-6551 standard
- IPAccountStorage: Storage contract for IP Account data
- IIPAccount: Interface for IP Account functionality
Functions
constructor
Creates a new IPAccountImpl contract instance.
Parameters:
accessController
: The address of the AccessController contract to be used for permission checksipAssetRegistry
: The address of the IP Asset RegistrylicenseRegistry
: The address of the License RegistrymoduleRegistry
: The address of the Module Registry
supportsInterface
Checks if the contract supports a specific interface.
Parameters:
interfaceId
: The interface identifier, as specified in ERC-165
Returns:
- Boolean indicating if the contract supports the interface
token
Returns the identifier of the non-fungible token which owns the account.
Returns:
chainId
: The EIP-155 ID of the chain the token exists ontokenContract
: The contract address of the tokentokenId
: The ID of the token
isValidSigner
Checks if the signer is valid for executing specific actions on behalf of the IP Account.
Parameters:
signer
: The signer to checkdata
: The data to be checked, encoded asabi.encode(address to, bytes calldata)
Returns:
- The function selector if the signer is valid, 0 otherwise
isValidSigner
Checks if the signer is valid for the given data and recipient via the AccessController permission system.
Parameters:
signer
: The signer to checkto
: The recipient of the transactiondata
: The calldata to check against
Returns:
- Boolean indicating if the signer is valid
owner
Returns the owner of the IP Account.
Returns:
- The address of the owner
state
Returns the IPAccount’s internal nonce for transaction ordering.
Returns:
- The current state (nonce) of the account
updateStateForValidSigner
Updates the IP Account’s state if the signer is valid for the given data and recipient.
Parameters:
signer
: The signer to checkto
: The recipient of the transactiondata
: The calldata to check against
executeWithSig
Executes a transaction from the IP Account on behalf of the signer.
Parameters:
to
: The recipient of the transactionvalue
: The amount of Ether to senddata
: The data to send along with the transactionsigner
: The signer of the transactiondeadline
: The deadline of the transaction signaturesignature
: The signature of the transaction, EIP-712 encoded
Returns:
- The return data from the transaction
execute
Executes a transaction from the IP Account.
Parameters:
to
: The recipient of the transactionvalue
: The amount of Ether to senddata
: The data to send along with the transaction
Returns:
- The return data from the transaction
execute
Executes a transaction from the IP Account with a specified operation type.
Parameters:
to
: The recipient of the transactionvalue
: The amount of Ether to senddata
: The data to send along with the transactionoperation
: The operation type to perform, only 0 - CALL is supported
Returns:
- The return data from the transaction
executeBatch
Executes a batch of transactions from the IP Account.
Parameters:
calls
: The array of calls to executeoperation
: The operation type to perform, only 0 - CALL is supported
Returns:
- The return data from the transactions
isValidSignature
ERC1271 signature verification is disabled for the IP Account.
Parameters:
hash
: The hash of the data to be signedsignature
: The signature to verify
Returns:
- Always returns 0xffffffff (disabled)
Events
Executed
Emitted when a transaction is executed from the IP Account.
Parameters:
to
: The recipient of the transactionvalue
: The amount of Ether sentdata
: The data sent along with the transactionstate
: The new state (nonce) of the account
ExecutedWithSig
Emitted when a transaction is executed from the IP Account on behalf of a signer.
Parameters:
to
: The recipient of the transactionvalue
: The amount of Ether sentdata
: The data sent along with the transactionstate
: The new state (nonce) of the accountdeadline
: The deadline of the transaction signaturesigner
: The signer of the transactionsignature
: The signature of the transaction
Security Considerations
The IPAccountImpl contract implements several security measures:
-
Permission System: Uses an AccessController to manage permissions for different signers and operations.
-
Signature Verification: Implements EIP-712 typed data signing for secure transaction authorization.
-
Deadline Checking: Includes transaction deadlines to prevent replay attacks.
-
Nonce Management: Uses a state (nonce) system to prevent transaction replay.
-
Input Validation: Validates inputs and checks for edge cases, such as preventing invalid operations.
-
Signature Malleability Protection: Includes protections against signature malleability attacks.
-
Limited Operations: Only supports the CALL operation (0) for security reasons, restricting potentially dangerous operations.
-
Upgradability Disabled: The contract disables UUPS upgradability to ensure contract immutability.
Usage Examples
Executing a Transaction
An IP asset owner can execute a transaction through their IP Account:
Executing with a Signature
A permitted signer can execute a transaction on behalf of the IP Account: