Skip to content

Create a new account

Category: Create Account

Description: Creates a new smart contract wallet and the account in the database related to it. The request body is a JSON (type ICreateAccountRequest) containing the params below.

Type: POST

URL: /create-account

Body Params (ICreateAccountRequest)

NameTypeRequired?Description
ownerstringyesThe address of the smart contract wallet owner
factoryAddressstringnoThe address of the smart contract wallet factory
_guardiansstring[]noThe guardians array in case of generalized account
_guardianIdstringnoThe guardians structId in case of shared storage account
_modulestringnoThe address of the module
saltnumbernoThe salt for counterfactual address generation
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 creating account
515Error during createAccountRequest parsing. Wrong input format for the createAccountRequest

Code Examples

Installation

tsx
npm i node-fetch
npm i node-fetch

Request

tsx
data: ICreateAccountRequest //input
const url =  `${this.backendUrl}/create-account`
let config = {
  method: "post",
  maxBodyLength: Infinity,
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${this.apiKey}`,
  },
  body: JSON.stringify(data),
};

const response = await fetch(url, config)
const JSONResponse = await response.json();
data: ICreateAccountRequest //input
const url =  `${this.backendUrl}/create-account`
let config = {
  method: "post",
  maxBodyLength: Infinity,
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${this.apiKey}`,
  },
  body: JSON.stringify(data),
};

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