Skip to content

Get the initCode

Category: Create Account

Description: Returns the initCode, useful for an account creation inside an userOperation. The request has a JSON as query param (IInitCodeRequest, that contains the parameters below)

Type: GET

URL: /initCode

Query Params (IInitCodeRequest)

NameTypeRequired?Description
ownerstringyesThe address of the smart contract wallet owner
factoryAddressstringnoThe address of the smart contract wallet factory
guardiansHashstringnoThe hash of the guardians array in case of generalized account
guardianIdstringnoThe guardians structId in case of shared storage account
moduleAddressstringnoThe address of the module
saltnumbernoThe salt for initCode generation
chainIdbigNumberishnoThe chainId for cross-chain handling

Error Handling

HTTP StatusMeaning
200OK
512Internal server error while retrieving initCode
515Error during initCodeRequest parsing. Wrong input format for the initCodeRequest

Code Examples

Installation

tsx
npm i node-fetch
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: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${this.apiKey}`,
  }
};

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

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

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