Java API

Paymaster Utilities

Essential utilities for using paymasters on ZKsync Era

The paymaster utilities contains essential utilities for using paymasters on ZKsync Era.

Contract interfaces

Constant ABI definition for the Paymaster Flow Interface.

Functions

encodeApprovalBased

Returns encoded input for an approval-based paymaster.

Inputs

ParameterTypeDescription
tokenAddressStringAddress of paymaster token.
minimalAllowanceBigIntegerPaymaster allowance.
inputbyte[]

encodeGeneral

As above but for general-based paymaster.

Inputs

ParameterTypeDescription
inputbyte[]

Examples

Creating General paymaster parameters.

PaymasterParams paymasterParams = new PaymasterParams(
  "0x0a67078A35745947A37A552174aFe724D8180c25",
  Numeric.hexStringToByteArray(FunctionEncoder.encode(
    Paymaster.encodeGeneral(
      new byte[] {})
     )
    )
  );

Creating ApprovalBased paymaster parameters.

PaymasterParams paymasterParams = new PaymasterParams(
  "0x0a67078A35745947A37A552174aFe724D8180c25",
  Numeric.hexStringToByteArray(FunctionEncoder.encode(
    Paymaster.encodeApprovalBased(
      "0x65C899B5fb8Eb9ae4da51D67E1fc417c7CB7e964",
      BigInteger.ONE,
      new byte[] {})
     )
    )
  );

zksync2-java examples

Check balance

Counter contract

Paymaster

Transfer

Withdraw


Made with ❤️ by the ZKsync Community