Interpreting EFP Data
A valid EFP list operation has four primary components that must exist in order for it to be considered active
.
-
a valid list storage location (denoting chainId, listRecords contract address, and slot)
-
an account metadata record specifying a tokenId as a user’s primary list
-
a list metadata record in the listRecords contract for ‘user’ role for the slot
-
a list record with a specified slot that matches the list metadata record and the list storage location. This list record must have been created on the list records contract and chain specified in the list storage location
The user and manager roles of a list can be different, this means that the sender of a transaction that applies list operations to a list is not necessarily the same address that is displayed as the user.
Connecting the dots
In order to validate a list operation, the data in each one of these components must match the others where specified.
If User Address is known:
If the only known information is a user address, then the following steps can be take to determine the user’s list, list storage location and slot
- Retrieve the user’s primary list by querying the account metadata contract using the user address.
- From the primary list, obtain the list storage location from the registry contract which includes the chainId, listRecords contract address, and slot using function getListStorageLocation(tokenId).
- Query the list metadata record in the listRecords contract using the slot to verify the ‘user’ role.
- Retrieve the list record from the listRecords contract using the slot and ensure it matches the list metadata record and list storage location in the registry.
If List Id is known:
If the only known information is a list number, then the following steps can be taken to determine the list user
- Obtain the list storage location from the registry contract which includes the chainId, listRecords contract address, and slot using function getListStorageLocation(tokenId).
- Query the list metadata record in the listRecords contract using the slot to verify the ‘user’ role. While at this step we will know the user address, we do not yet know if the user role is valid without checking for the existance of a ‘primary-list’ record that matches this list id and the user’s address.
- Retrieve the user’s primary list by querying the account metadata contract using the user address.
- Retrieve the list record from the listRecords contract using the slot and ensure it matches the list metadata record and list storage location in the registry.
If Slot is known:
If the only known information is the slot (i.e. you’re looking at a raw list operation and want to determine the list to which it applies)
- Query the list metadata record in the listRecords contract using the slot to find the ‘user’ role. While at this step we will know the user address, we do not yet know if the user role is valid without checking for the existance of a ‘primary-list’ record that matches this list id and the user’s address.
- Retrieve the user’s primary list by querying the account metadata contract using the user address.
Interpreting an example List Operation
A List Record specifies a slot (which is specific to a list’s list storage location) and an operation which describes the action being taken and the address it relates to. For instance the record below is a follow record for address 0x983110309620d911731ac0932219af06091b6744
The op
data of this list record can be further broken down and abstracted into its constituant parts
This record only tells us the slot
of the list that’s doing the following but it tells us nothing about which account or list is doing the following. To determine the list doing the following we need to join the slot, chain id and the address of the list records contract and construct a list storage location.
Interpreting an example List Storage Location
This list storage location can be interpreted as follows
Constructing State History
A repository demonstrating practical application of this page that can be found here:
https://github.com/ethereumfollowprotocol/onchain
Interacting with Contracts directly
Calling the Account Metadata contract to fetch a user’s primary list:
Calling the List Registry contract to fetch a list’s list storage location:
Calling the List Records contract to fetch a list slot’s ‘user’ role:
Relevant Contract Events
Basic EFP state for any user’s followers and followings can also be constructed by ‘listening’ for specific events emitted by the EFP contracts and then interpreting them according to the protocol rules as stated above
EFPListRecords (Base, Optimism and Ethereum Mainnet)
ListOp(uint256 indexed slot, bytes op)
UpdateListMetadata(uint256 indexed slot, string key, bytes value)
EFPAccountMetadata (Base)
UpdateAccountMetadata(address indexed addr, string key, bytes value)
EFPListRegistry (Base)
UpdateListStorageLocation(uint256 indexed tokenId, bytes listStorageLocation)