Skip to content

Send a userOperation

Category: User Operations

Description: Sends an ERC-4337 userOperation to the bundler, that will execute it (the request type is IUserOperation, a JSON containing the fields in body params)

Type: POST

URL: /send-op

Body Params (IUserOperation)

NameTypeRequired?Description
senderstringyesThe address of the sender smart contract wallet
noncebigNumberishyesThe nonce of the sender smart contract wallet
initCodebytesLikeyesThe init code of the sender smart contract wallet
callDatabytesLikeyesThe data to be sent to the sender smart contract account during execution
callGasLimitbigNumberishyesThe gas limit for the execution of the callData
verificationGasLimitbigNumberishyesThe gas limit for the verification of the signature and the nonce of the userOperation
preVerificationGasbigNumberishyesThe gas limit for all the operations before the verification of the signature and the nonce of the userOperation
maxFeePerGasbigNumberishyesThe maximum fee per gas unit that can be paid by the userOperation
maxPriorityFeePerGasbigNumberishyesThe maximum priority fee per gas unit that can be paid by the userOperation
paymasterAndDatabytesLikeyesThe address of the paymaster address that will sponsor the userOperation and further data required by the paymaster smart contract. This parameter can be left blank if the userOperation doesn't have to be sponsored
signaturebytesLikeyesThe signature of the userOperation
webHookDataIWebHookRequestnoData structure with two fields, a tag that represents the endpoint that will be called from the webhook, and an optional metadata that represents a generic object that will be returned by the backend with the webhook call

IWebHookRequest detail

ts
interface IWebHookRequest {
    tag : string;
    metadata? : Record<string, unknown>;
}
interface IWebHookRequest {
    tag : string;
    metadata? : Record<string, unknown>;
}

Error Handling

HTTP StatusMeaning
200OK
512Internal server error while sending userOperation
515Error during send-userOp request parsing. Wrong input format for the userOperation
516Error received from the bundler while handling the userOperation

Code Examples

Installation

tsx
npm i node-fetch
npm i node-fetch

Request

tsx
data: IUserOperation
const url = `${this.backendUrl}/send-op`;
let config = {
  method: "post",
  body: JSON.stringify(data),
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${this.apiKey}`,
  },

};


const response = await fetch(url, config)
data: IUserOperation
const url = `${this.backendUrl}/send-op`;
let config = {
  method: "post",
  body: JSON.stringify(data),
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${this.apiKey}`,
  },

};


const response = await fetch(url, config)