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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<Transport, Chain, Account> | The viem client with account to use for the transaction. |
options | OptionsType | setOperatorApproval.OptionsType |
Returns
Section titled “Returns”Promise<`0x${string}`>
The transaction hash
Throws
Section titled “Throws”Errors setOperatorApproval.ErrorType
Example
Section titled “Example”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 defaultsconst hash = await setOperatorApproval(client, { approve: true,})
// Revoke operatorconst revokeHash = await setOperatorApproval(client, { approve: false,})
console.log(hash)