Skip to content

setOperatorApprovalCall

setOperatorApprovalCall(options): OutputType

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

Create a call to the setOperatorApproval function

This function is used to create a call to the setOperatorApproval function for use with sendCalls, sendTransaction, multicall, estimateContractGas, or simulateContract.

ParameterTypeDescription
options{ approve: boolean; chain: Chain; contractAddress?: `0x${string}`; lockupAllowance?: bigint; maxLockupPeriod?: bigint; operator?: `0x${string}`; rateAllowance?: bigint; token?: `0x${string}`; }setOperatorApprovalCall.OptionsType
options.approvebooleanWhether to approve (true) or revoke (false) the operator.
options.chainChainThe chain to use to make the call.
options.contractAddress?`0x${string}`Payments contract address. If not provided, the default is the payments contract address for the chain.
options.lockupAllowance?bigintMaximum lockup amount the operator can use (in token base units). Defaults to maxUint256 when approving, 0n when revoking.
options.maxLockupPeriod?bigintMaximum lockup period in epochs the operator can set for payment rails. Defaults to 30 days in epochs when approving, 0n when revoking.
options.operator?`0x${string}`The address of the operator to approve/revoke. If not provided, the Warm Storage contract address will be used.
options.rateAllowance?bigintMaximum rate the operator can use per epoch (in token base units). Defaults to maxUint256 when approving, 0n when revoking.
options.token?`0x${string}`The address of the ERC20 token. If not provided, the USDFC token address will be used.

OutputType

The call to the setOperatorApproval function setOperatorApprovalCall.OutputType

Errors setOperatorApprovalCall.ErrorType

import { setOperatorApprovalCall } from '@filoz/synapse-core/pay'
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { simulateContract } from 'viem/actions'
import { calibration } from '@filoz/synapse-core/chains'
const account = privateKeyToAccount('0x...')
const client = createWalletClient({
account,
chain: calibration,
transport: http(),
})
// Use with simulateContract
const { request } = await simulateContract(client, setOperatorApprovalCall({
chain: calibration,
approve: true,
}))
console.log(request)