DocsFunctionsList Operations

List Operations

The list operations module provides utility functions for creating list operations in the EFP (Ethereum Follow Protocol) system.

List operations are a way to manage lists on the EFP (Ethereum Follow Protocol). They are used to add, remove, and tag records in a list. For more detailed information, see the EFP Docs - List Operations.

⚠️

When using these functions, ensure that the provided Ethereum addresses are valid and properly formatted.

Import

import { listOpAddListRecord, listOpRemoveListRecord, listOpAddTag, listOpRemoveTag } from 'ethereum-identity-kit'
 
// For server side usage
import { listOpAddListRecord, listOpRemoveListRecord, listOpAddTag, listOpRemoveTag } from 'ethereum-identity-kit/utils'

Functions

listOpAddListRecord

Creates a list operation to add a new record to a list.

const op = listOpAddListRecord('0x...')

Parameters

ParameterTypeDescription
addressAddressThe Ethereum address to add to the list

Return Value

Returns a ListOpType object:

{
  version: 1,
  opcode: Opcode.FOLLOW,
  data: address
}

listOpRemoveListRecord

Creates a list operation to remove a record from a list.

const op = listOpRemoveListRecord('0x...')

Parameters

ParameterTypeDescription
addressAddressThe Ethereum address to remove from the list

Return Value

Returns a ListOpType object:

{
  version: 1,
  opcode: Opcode.UNFOLLOW,
  data: address
}

listOpAddTag

Creates a list operation to add a tag to a list record.

const op = listOpAddTag('0x...', 'friend')

Parameters

ParameterTypeDescription
addressAddressThe Ethereum address to tag
tagstringThe tag to add

Return Value

Returns a ListOpType object:

{
  version: 1,
  opcode: Opcode.TAG,
  data: `${address}${toHex(tag).slice(2)}`
}

listOpRemoveTag

Creates a list operation to remove a tag from a list record.

const op = listOpRemoveTag('0x...', 'friend')

Parameters

ParameterTypeDescription
addressAddressThe Ethereum address to remove the tag from
tagstringThe tag to remove

Return Value

Returns a ListOpType object:

{
  version: 1,
  opcode: Opcode.UNTAG,
  data: `${address}${toHex(tag).slice(2)}`
}