INDID Admin SDK
The admin sdk provides all the methods and functionalities of the core sdk, it also provides the following:
init
A method for obtaining an initialized instance of the sdk
const clientAdmin = await AdminClient.init(
config: IClientConfig
);It's possible to pass optional parameters to the init method, such as the entry point, the override bundler rpc url, the override backend url and the log level. The log level defaults to NONE, which means no logs will be printed.
interface IClientConfig {
apiKey: string;
rpcUrl?: string;
chainId?: BigNumberish;
overrideBundlerRpc?: string;
overrideBackendUrl?: string;
overrideEntryPoint?: string;
logLevel?: LogLevel;
}enum LogLevel {
NONE,
DEBUG,
INFO,
WARNING,
ERROR,
}createAccount
A method for creating(deploying) a smart contract wallet, requires Credits. The salt defaults to 0 and should be changed only if the same owner wants to deploy multiple smart contract wallets. The field opts is only needed when the values set at project creation should be overridden.
Returns the address and the task ID of the deploy transaction inside an ICreateAccountResponse.
const response = await clientAdmin.createAccount(
owners: IndidAddress[],
salt?: string,
webhookData?: IWebHookRequest,
opts?: ICreateAccountOpts
);Interfaces
interface IWebHookRequest {
tag: string;
metadata?: Record<string, unknown>;
}interface ICreateAccountOpts {
storageType: "standard" | "shared";
moduleType: "user" | "enterprise";
factoryAddress: string;
moduleAddress: string;
guardians: IndidAddress[];
beaconId?: BytesLike;
}interface ICreateAccountResponse {
accountAddress: string;
taskId: string;
error?: string;
}Parameters
Takes the following parameters:
owners: An array ofIndidAddressobjects representing the account ownerssalt(optional): A unique value to ensure deployment address uniqueness. Defaults to "0"webhookData(optional): Configuration for webhook notifications about the deployment processopts(optional): Configuration options to override default project settings:storageType: The type of storage to use for the accountmoduleType: The type of module to use for the accountfactoryAddress: The address of the account factory contractmoduleAddress: The address of the module contractguardians: An array of guardian addresses for the accountbeaconId: Optional beacon ID for shared storage accounts
Returns
Returns an object containing:
accountAddress: The address of the newly created smart contract wallettaskId: A unique identifier for tracking the deployment processerror: Optional error message if the request fails
Example Usage
// Prepare the account parameters
const ownerPrivateKey = "0x123...";
const wallet = new ethers.Wallet(ownerPrivateKey);
const ownerAddress = IndidAddress.fromSecp256k1(wallet.address);
// Create the account
const response = await clientAdmin.createAccount(
[ownerAddress],
"1" // Salt
);
console.log(`Created account at address: ${response.accountAddress}`);
// Monitor the deployment process
const result = await clientAdmin.waitTask(response.taskId);
console.log(`Deployment status: ${result.status}`);The returned task ID can be used with the waitTask method to monitor the deployment process status. If a webhook was configured, updates will also be sent to the specified endpoint.
createAndConnectAccount
A method for creating(deploying) a SCW, requires Credits. The salt defaults to 0 and should be changed only if the same owner wants to deploy multiple smart contract wallets. The field opts is only needed when the values set at project creation should be overridden. It will always wait internally for the deploy transaction to be validated and then connect to the newly created account.
Returns the address and the task ID of the deploy transaction inside an ICreateAccountResponse. If no signer has been provided it also returns the seed of the newly created signer.
const response = await clientAdmin.createAndConnectAccount(
signer: IndidSigner,
salt?: string,
webhookData?: IWebHookRequest,
opts?: ICreateAccountOpts
);interface IWebHookRequest {
tag: string;
metadata?: Record<string, unknown>;
}interface ICreateAccountOpts {
storageType: "standard" | "shared";
moduleType: "user" | "enterprise";
factoryAddress: string;
moduleAddress: string;
guardians: IndidAddress[];
beaconId?: BytesLike;
}interface ICreateAndConnectAccountResponse {
accountAddress: string;
taskId: string;
error?: string;
}getUserOpSponsorship
A method for getting a User Operation Sponsored, it consumes Credits.
It applies the PaymasterAndData field on the builder itself. If only the field is needed it can be retrieved from the IUserOpSponsorshipResponse.
const response = await clientAdmin.getUserOpSponsorship(
builder: IUserOperationBuilder
);Interfaces
interface IUserOpSponsorshipResponse {
paymasterAndData: string;
error?: string;
}Parameters
Takes the following parameters:
builder: AnIUserOperationBuilderobject containing the user operation to be sponsored
Returns
Returns an object containing:
paymasterAndData: The paymaster data needed to sponsor the user operationerror: Optional error message if the request fails
Example Usage
// Get sponsorship for the user operation
const response = await clientAdmin.getUserOpSponsorship(builder);
// The builder now has the paymaster data applied to it
// Alternatively, you can access the paymaster data directly
console.log(`PaymasterAndData: ${response.paymasterAndData}`);Note that the sponsorship is automatically applied to the builder object. The operation can be sent immediately after getting sponsorship without any additional steps.
recoverEnterpriseAccount
A method for changing the owner of an existing smart contract account, it consumes Credits. GuardianSigner is the signer of the wallet's guardian.
Returns a taskID inside IRecoverAccountResponse.
const response = await clientAdmin.recoverEnterpriseAccount(
accountAddress: string,
newOwner: IndidAddress,
guardianSigner: IndidSigner,
webhookData?: IWebHookRequest
);Interfaces
interface IWebHookRequest {
tag: string;
metadata?: Record<string, unknown>;
}interface IRecoverAccountResponse {
taskId: string;
error?: string;
}Returns
Returns an object containing:
taskId: A unique identifier for tracking the recovery processerror: Optional error message if the request fails
Example Usage
// Prepare the recovery parameters
const accountToRecover = "0x123..."; // The address of the account to recover
const newOwnerAddress = IndidAddress.fromSecp256k1("0x456..."); // The new owner's address
const guardianPrivateKey = "0x789..."; // The guardian's private key
const wallet = new ethers.Wallet(guardianPrivateKey);
const guardianSigner = IndidSigner.fromSecp256k1(
wallet.privateKey,
SignerKind.Guardian
);
// Optional webhook data
const webhook = {
tag: "account-recovery",
metadata: {
reason: "lost access",
requestedBy: "support-team-123",
},
};
// Initiate account recovery
const response = await clientAdmin.recoverEnterpriseAccount(
accountToRecover,
newOwnerAddress,
guardianSigner,
webhook
);
// Monitor the recovery process
const result = await clientAdmin.waitTask(response.taskId);
console.log(`Recovery status: ${result.status}`);The returned task ID can be used with the waitTask method to monitor the recovery process status. If a webhook was configured, updates will also be sent to the specified endpoint.
sendDelegatedTransactions
A method for sending a batch of delegated transactions, requires Credits. If the provider/chainId are not provided at initialization they chaindId be required in this function. The webhookData is optional and can be used to specify a webhook to be called upon the transactions success or failure. Returns a taskID inside ISendDelegatedTransactionsResponse.
const response = await clientAdmin.sendDelegatedTransactions(
transactions: ICall[],
opts?: IDelegatedTransactionOptions
);Interfaces
interface IDelegatedTransactionOptions {
chainId?: BigNumberish;
doNotRevertOnTxFailure?: boolean;
deadlineSeconds?: number;
webhookData?: IWebHookRequest;
}The tag field is mandatory and represents the specific webhook to be called upon the operation completion. Metadata is optional and can be used to pass additional information to the webhook that will be returned with the webhook callback.
interface IWebHookRequest {
tag: string;
metadata?: Record<string, unknown>;
}interface ISendDelegatedTransactionsResponse {
taskId: string;
error?: string;
}Parameters
Takes the following parameters:
transactions: An array ofICallobjects representing the transactions to be executedopts(optional): Configuration options for transaction execution, including:chainId: The blockchain network identifier (required if not provided during initialization)doNotRevertOnTxFailure: Flag to continue execution even if a transaction failsdeadlineSeconds: Expiration time in seconds after which the transaction becomes invalidwebhookData: Configuration for webhook notifications
Returns
Returns an object containing:
taskId: A unique identifier for tracking the transaction executionerror: Optional error message if the request fails
Example Usage
// Define transactions to execute
const transactions = [
{
to: "0x123...",
value: ethers.utils.parseEther("0.1"),
data: "0x",
},
{
to: "0x456...",
value: 0,
data: "0x789...", // Contract interaction data
},
];
// Set options
const options = {
chainId: 1,
deadlineSeconds: 3600, // 1 hour
webhookData: {
tag: "batch-transfer",
metadata: {
purpose: "weekly payments",
},
},
};
// Send delegated transactions
const response = await clientAdmin.sendDelegatedTransactions(
transactions,
options
);
// Monitor the transaction status
const result = await clientAdmin.waitTask(response.taskId);sendPreparedDelegatedTransactions
A method for sending a previously prepared delegated transaction to the INDID backend. This method executes transactions that have been signed by the account owner but are submitted through a delegated sender.
const response = await clientAdmin.sendPreparedDelegatedTransactions(
preparedTransaction: ISendDelegatedTransactionsRequest
);Interfaces
interface ISendDelegatedTransactionsRequest {
accountAddress: string;
chainId: BigNumberish;
moduleAddress: string;
data: BytesLike;
nonce: BigNumberish;
deadline: number;
sigs: BytesLike;
webhookData?: IWebHookRequest;
}interface ISendDelegatedTransactionsResponse {
taskId: string;
error?: string;
}Parameters
Takes a preparedTransaction object with the following properties:
accountAddress: The smart contract account address that will execute the transactionchainId: The blockchain network identifiermoduleAddress: The address of the module contract handling the transactiondata: The encoded transaction calldatanonce: A unique number to prevent replay attacksdeadline: Expiration time in seconds after which the transaction becomes invalidsigs: The signatures authorizing the transactionwebhookData(optional): Configuration for webhook notifications
Returns
Returns an object containing:
taskId: A unique identifier for tracking the transaction executionerror: Optional error message if the request fails
Example Usage
// First prepare the delegated transaction
const preparedTx: ISendDelegatedTransactionsRequest = {
accountAddress: "0x123...",
chainId: 1,
moduleAddress: "0x456...",
data: "0x789...",
nonce: 1,
deadline: 3600, // 1 hour from now
sigs: "0xabc...",
webhookData: {
tag: "transfer-eth",
metadata: {
type: "payment",
amount: "1.5 ETH",
},
},
};
// Send the prepared transaction
const response = await clientAdmin.sendPreparedDelegatedTransactions(
preparedTx
);
// Monitor the transaction status
const result = await clientAdmin.waitTask(response.taskId);The returned task ID can be used with the waitTask method to monitor the transaction's execution status. If a webhook was configured, updates will also be sent to the specified endpoint.