tokenApproveOperation static method

UserOperation tokenApproveOperation(
  1. EthereumAddress contractAddress,
  2. EthereumAddress owner,
  3. EthereumAddress spender,
  4. EtherAmount amount
)

Returns the UserOperation for an ERC20 approval.

  • contractAddress: The 4337 wallet address.
  • owner: The address of the approved owner.
  • spender: The address of the approved spender.
  • amount: The amount to approve for the spender.

Returns the UserOperation.

Implementation

static UserOperation tokenApproveOperation(
  EthereumAddress contractAddress,
  EthereumAddress owner,
  EthereumAddress spender,
  EtherAmount amount,
) {
  final callData = execute(owner,
      to: contractAddress,
      innerCallData:
          encodeERC20ApproveCall(contractAddress, spender, amount));
  return UserOperation.partial(callData: hexlify(callData));
}