IPAssetRegistry.sol

This contract acts as the source of truth for all IP registered in Story Protocol. An IP is identified by its contract address, token id, and coin type, meaning any NFT may be conceptualized as an IP. Once an IP is registered into the protocol, a corresponding IP asset is generated, which references an IP resolver for metadata attribution and an IP account for protocol authorization.

IMPORTANT: The IP account address, besides being used for protocol auth, is also the canonical IP identifier for the IP NFT.

MODULE_REGISTRY

contract IModuleRegistry MODULE_REGISTRY

The canonical module registry used by the protocol.

REGISTRATION_MODULE

contract IRegistrationModule REGISTRATION_MODULE

The registration module that interacts with IPAssetRegistry.

totalSupply

uint256 totalSupply

Tracks the total number of IP assets in existence.

isApprovedForAll

mapping(address => mapping(address => bool)) isApprovedForAll

Checks whether an operator is approved to register on behalf of an IP owner.

_records

mapping(address => struct IIPAssetRegistry.Record) _records

Maps an IP, identified by its IP ID, to an IP record.

_metadataProvider

contract IMetadataProviderMigratable _metadataProvider

Tracks the current metadata provider used for IP registrations.

constructor

constructor(address erc6551Registry, address ipAccountImpl, address moduleRegistry, address governance) public

TODO: Utilize module registry for fetching different modules.

setApprovalForAll

function setApprovalForAll(address operator, bool approved) external

Enables third party operators to register on behalf of an NFT owner.

Parameters

NameTypeDescription
operatoraddressThe address of the operator the sender authorizes.
approvedboolWhether or not to approve that operator for registration.

setRegistrationModule

function setRegistrationModule(address registrationModule) external

Sets the registration module that interacts with IPAssetRegistry.

Parameters

NameTypeDescription
registrationModuleaddressThe address of the registration module.

setMetadataProvider

function setMetadataProvider(address newMetadataProvider) external

Sets the provider for storage of new IP metadata, while enabling existing IP assets to migrate their
metadata to the new provider.

Parameters

NameTypeDescription
newMetadataProvideraddressAddress of the new metadata provider contract.

register

function register(uint256 chainId, address tokenContract, uint256 tokenId, address resolverAddr, bool createAccount, bytes metadata_) external returns (address ipId_)

Registers an NFT as IP, creating a corresponding IP record.

Parameters

NameTypeDescription
chainIduint256The chain identifier of where the NFT resides.
tokenContractaddressThe address of the NFT.
tokenIduint256The token identifier of the NFT.
resolverAddraddressThe address of the resolver to associate with the IP.
createAccountboolWhether to create an IP account when registering.
metadata_bytesMetadata in bytes to associate with the IP.

Return Values

NameTypeDescription
ipId_addressThe address of the newly registered IP.

register

function register(uint256[] licenseIds, bytes royaltyContext, uint256 chainId, address tokenContract, uint256 tokenId, address resolverAddr, bool createAccount, bytes metadata_) external returns (address ipId_)

Registers an NFT as an IP using licenses derived from parent IP asset(s).

Parameters

NameTypeDescription
licenseIdsuint256[]The parent IP asset licenses used to derive the new IP asset.
royaltyContextbytesThe context for the royalty module to process.
chainIduint256The chain identifier of where the NFT resides.
tokenContractaddressThe address of the NFT.
tokenIduint256The token identifier of the NFT.
resolverAddraddressThe address of the resolver to associate with the IP.
createAccountboolWhether to create an IP account when registering.
metadata_bytesMetadata in bytes to associate with the IP.

Return Values

NameTypeDescription
ipId_addressThe address of the newly registered IP.

ipId

function ipId(uint256 chainId, address tokenContract, uint256 tokenId) public view returns (address)

Gets the canonical IP identifier associated with an IP NFT.

This is equivalent to the address of its bound IP account.

Parameters

NameTypeDescription
chainIduint256The chain identifier of where the IP resides.
tokenContractaddressThe address of the IP.
tokenIduint256The token identifier of the IP.

Return Values

NameTypeDescription
[0]addressipId The IP's canonical address identifier.

isRegistered

function isRegistered(address id) external view returns (bool)

Checks whether an IP was registered based on its ID.

Parameters

NameTypeDescription
idaddressThe canonical identifier for the IP.

Return Values

NameTypeDescription
[0]boolisRegistered Whether the IP was registered into the protocol.

resolver

function resolver(address id) external view returns (address)

Gets the resolver bound to an IP based on its ID.

Parameters

NameTypeDescription
idaddressThe canonical identifier for the IP.

Return Values

NameTypeDescription
[0]addressresolver The IP resolver address if registered, else the zero address.

metadataProvider

function metadataProvider() external view returns (address)

Gets the metadata provider used for new metadata registrations.

Return Values

NameTypeDescription
[0]addressmetadataProvider The address of the metadata provider used for new IP registrations.

metadataProvider

function metadataProvider(address id) external view returns (address)

Gets the metadata provider linked to an IP based on its ID.

Parameters

NameTypeDescription
idaddressThe canonical identifier for the IP.

Return Values

NameTypeDescription
[0]addressmetadataProvider The metadata provider that was bound to this IP at creation time.

metadata

function metadata(address id) external view returns (bytes)

Gets the underlying canonical metadata linked to an IP asset.

Parameters

NameTypeDescription
idaddressThe canonical ID of the IP asset.

Return Values

NameTypeDescription
[0]bytesmetadata The metadata that was bound to this IP at creation time.

setMetadata

function setMetadata(address id, address provider, bytes data) external

Sets the underlying metadata for an IP asset.

As metadata is immutable but additive, this will only be used when an IP migrates from a new provider that
introduces new attributes.

Parameters

NameTypeDescription
idaddressThe canonical ID of the IP.
provideraddress
databytesCanonical metadata to associate with the IP.

setResolver

function setResolver(address id, address resolverAddr) public

Sets the resolver for an IP based on its canonical ID.

Parameters

NameTypeDescription
idaddressThe canonical ID of the IP.
resolverAddraddressThe address of the resolver being set.

_register

function _register(uint256[] licenseIds, bytes royaltyContext, uint256 chainId, address tokenContract, uint256 tokenId, address resolverAddr, bool createAccount, bytes data) internal returns (address id)

Registers an NFT as an IP.

Parameters

NameTypeDescription
licenseIdsuint256[]IP asset licenses used to derive the new IP asset, if any.
royaltyContextbytesThe context for the royalty module to process.
chainIduint256The chain identifier of where the NFT resides.
tokenContractaddressThe address of the NFT.
tokenIduint256The token identifier of the NFT.
resolverAddraddressThe address of the resolver to associate with the IP.
createAccountboolWhether to create an IP account when registering.
databytesCanonical metadata to associate with the IP.

_setResolver

function _setResolver(address id, address resolverAddr) internal

Sets the resolver for the specified IP.

Parameters

NameTypeDescription
idaddressThe canonical ID of the IP.
resolverAddraddressThe address of the resolver being set.

_setMetadata

function _setMetadata(address id, contract IMetadataProviderMigratable provider, bytes data) internal

Sets the for the specified IP asset.

Parameters

NameTypeDescription
idaddressThe canonical identifier for the specified IP asset.
providercontract IMetadataProviderMigratableThe metadata provider hosting the data.
databytesThe metadata to set for the IP asset.