Skip to content

setOperatorApproval

setOperatorApproval(client, options): Promise<`0x${string}`>

Defined in: packages/synapse-core/src/pay/set-operator-approval.ts:82

Set operator approval on the Filecoin Pay contract

Approves or revokes an operator to act on behalf of the caller’s account. When approving, defaults to maximum allowances (maxUint256) and 30-day lockup period. When revoking, defaults to zero allowances.

ParameterTypeDescription
clientClient<Transport, Chain, Account>The viem client with account to use for the transaction.
optionsOptionsTypesetOperatorApproval.OptionsType

Promise<`0x${string}`>

The transaction hash

Errors setOperatorApproval.ErrorType

import { setOperatorApproval } from '@filoz/synapse-core/pay'
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { calibration } from '@filoz/synapse-core/chains'
const account = privateKeyToAccount('0x...')
const client = createWalletClient({
account,
chain: calibration,
transport: http(),
})
// Approve operator with defaults
const hash = await setOperatorApproval(client, {
approve: true,
})
// Revoke operator
const revokeHash = await setOperatorApproval(client, {
approve: false,
})
console.log(hash)