DocsFunctionsTransactions

Transactions

The transactions module provides utility functions for handling EFP (Ethereum Follow Protocol) list operations and transactions.

Import

import {
  formatListOpsTransaction,
  getListOpData,
  getListOpsFromTransaction,
  getMintTxNonce,
  getMintTxChainId,
  getMintTxRecordsAddress,
  getPendingTxAddresses,
  extractAddressAndTag,
  getPendingTxListOps,
  getPendingTxAddressesAndTags,
  prepareMintTransaction,
  transformTxsForLocalStorage,
} from 'ethereum-identity-kit'
 
// For server side usage
import {
  formatListOpsTransaction,
  getListOpData,
  getListOpsFromTransaction,
  getMintTxNonce,
  getMintTxChainId,
  getMintTxRecordsAddress,
  getPendingTxAddresses,
  extractAddressAndTag,
  getPendingTxListOps,
  getPendingTxAddressesAndTags,
  prepareMintTransaction,
  transformTxsForLocalStorage,
} from 'ethereum-identity-kit/utils'

Functions

formatListOpsTransaction

Formats a list operations transaction with the provided parameters. Use this only if you are trying to execute EFP transactions yourself. If you are using TransactionProvider with useTransaction, and are using the addlistopstransaction function, you don’t need to use it.

const transaction = formatListOpsTransaction({
  nonce: 1n,
  chainId: 1,
  listOps: [{ opcode: 1, data: '0x...' }],
  connectedAddress: '0x...',
  isMintingNewList: false,
})

Parameters

ParameterTypeDescription
noncebigintThe nonce for the transaction
chainIdnumberThe chain ID to use
listOpsListOpType[]Array of list operations to perform
connectedAddressAddressThe connected wallet address
isMintingNewListbooleanWhether this is for minting a new list

getListOpData

Generates list operation data from an address and optional tag.

const data = getListOpData('0x...', 'tag')

Parameters

ParameterTypeDescription
addressAddressThe Ethereum address
tagstringOptional tag to include

getListOpsFromTransaction

Extracts list operations from a transaction.

const listOps = getListOpsFromTransaction(transaction)

Parameters

ParameterTypeDescription
transactionTransactionTypeThe transaction to extract operations from

getMintTxNonce

Extracts the nonce from a mint transaction.

const nonce = getMintTxNonce(transaction)

getMintTxChainId

Extracts the chain ID from a mint transaction.

const chainId = getMintTxChainId(transaction)

getMintTxRecordsAddress

Extracts the records address from a mint transaction.

const recordsAddress = getMintTxRecordsAddress(transaction)

getPendingTxAddresses

Gets all addresses from pending list update transactions.

const addresses = getPendingTxAddresses(transactions)

extractAddressAndTag

Extracts address and tag from list operation data.

const { address, tag } = extractAddressAndTag(data)

getPendingTxListOps

Gets all list operations from pending transactions.

const listOps = getPendingTxListOps(transactions)

getPendingTxAddressesAndTags

Gets all addresses and tags from pending transactions.

const addressesAndTags = getPendingTxAddressesAndTags(transactions)

prepareMintTransaction

Prepares a mint transaction with the given parameters.

const mintTx = prepareMintTransaction(mintNonce, chainId)

Parameters

ParameterTypeDescription
mintNoncebigintThe nonce for the mint transaction
chainIdnumberOptional chain ID to use

transformTxsForLocalStorage

Transforms transactions for local storage by converting bigint values to strings.

const transformedTxs = transformTxsForLocalStorage(transactions)

Parameters

ParameterTypeDescription
txsTransactionType[]Array of transactions to transform