Skip to content

Sign a userOperation for Paymaster sponsorization ​

Category: User Operations

Description: This endpoint streamlines gasless transactions by completing a partial ERC-4337 userOperation (missing paymasterAndData and signature). The INDID backend validates that the Paymaster is authorized to sponsor the operation, signs the userOperation by adding the Paymaster data, and locks the maximum estimated CU amount from the user's credit (with a refund if the actual cost is lower). It returns the userOperation with the signed paymasterAndData, ready to be forwarded to the Bundler so your app can pay gas fees on behalf of the end user.

Type: POST

URL: /sign-paymaster-op

Requirements ​

  • A valid API Key must be provided (header Authorization: Bearer <API_KEY>)
  • The provided chainId must be configured for the project
  • The Account Abstraction module must be enabled for the project

Body Params (IUserOperation) ​

The userOperation must NOT include paymasterAndData and signature.

NameTypeDescriptionRequired?
senderstringThe address of the sender smart contract wallet✅
noncebigNumberishThe nonce of the sender smart contract wallet✅
initCodebytesLikeThe init code of the sender smart contract wallet✅
callDatabytesLikeThe data to be sent to the sender smart contract account during execution✅
callGasLimitbigNumberishThe gas limit for the execution of the callData✅
verificationGasLimitbigNumberishThe gas limit for the verification of the signature and the nonce of the userOperation✅
preVerificationGasbigNumberishThe gas limit for all the operations before the verification of the signature and the nonce of the userOperation✅
maxFeePerGasbigNumberishThe maximum fee per gas unit that can be paid by the userOperation✅
maxPriorityFeePerGasbigNumberishThe maximum priority fee per gas unit that can be paid by the userOperation✅

Response ​

ts
type SignPaymasterOpResponse = {
  paymasterAndData: string; // Signed paymaster data to include in the userOperation
};

Error Handling ​

HTTP StatusMeaning
200OK
403Unauthorized userOperation - validation failure
512Internal server error while signing userOperation
515Error during partial userOp parsing. Wrong input format for the partial userOp

Code Examples ​

Installation ​

tsx
npm i node-fetch

Request ​

tsx
data: IUserOperation;
const dataWithChainId = {
  ...data,
  chainid: this.chainId,
};

const url = `${this.backendUrl}/sign-paymaster-op`;
let config = {
  method: "post",
  maxBodyLength: Infinity,
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${this.apiKey}`,
  },
  body: JSON.stringify(dataWithChainId),
};

const response = await fetch(url, config);
const JSONResponse = await response.json();