Skip to content

Get the initCode ​

Category: Create Account

Description: Provides the initCode, an essential value for initializing and creating a new account within a userOperation.

Type: GET

URL: /initCode

Authentication ​

Public endpoint — no authentication required.

Query Params (IInitCodeRequest) ​

NameTypeDescriptionRequired
factoryAddressstringFactory contract address✅
ownerIWalletOwnerThe wallet owner✅
guardiansIndidGuardian[]Array of associated guardians✅
guardianBytesstringGuardians data encoded as bytes✅
moduleAddressstringModule address✅
saltBigNumberishSalt value✅
chainIdChainIdChain ID✅
guardianIdstringOptional guardian ID (for shared storage accounts)

Response ​

ts
type GetInitCodeResponse = {
  initCode: string; // The initialization code required for account creation
};

Error Handling ​

HTTP StatusMeaning
200InitCode retrieved successfully
512Internal server error while retrieving initCode
515Parsing error: wrong input format for the initCodeRequest

Code Examples ​

Installation ​

tsx
npm i node-fetch

Request ​

tsx
params: IInitCodeRequest;

const url =
  `${this.backendUrl}/initCode?` + new URLSearchParams({ ...(params as any) });
let config = {
  method: "get",
  maxBodyLength: Infinity,
  headers: {},
};

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