# Add Owners

```typescript
import { ethers } from 'ethers';
import 'dotenv/config';
import { NetworkNames, initializeSdkGateway } from '@kanalabs/mirai';
import { sleep } from '@etherspot/prime-sdk/dist/sdk/common';

async function main() {

  // initializating sdk...
  const sdk = await initializeSdkGateway(
    { privateKey: process.env.PRIVATE_KEY as string },
    {
      networks: [NetworkNames.Mumbai],
      bundlerApiKey: process.env.BUNDLER_API_KEY,
    },
  );

  const networkInstance = sdk.setCurrentInstance(NetworkNames.Mumbai);
  console.log('address: ', networkInstance.state.EOAAddress);

  // get address of EtherspotWallet
  const address: string = await networkInstance.getCounterFactualAddress();

  // update the addresses in this array with the owner addresses you want to set
  const ownerAddresses: string[] = [
    '0x838491825187FF13ed4a4476De3E28D4404da3Be',
    '0xC39Ccf6319A6c4079f21c3573B63956f7bbd851C'
  ];

  console.log('\x1b[33m%s\x1b[0m', `EtherspotWallet address: ${address}`);

  const addOwnerInterface = new ethers.utils.Interface(['function addOwner(address _newOwner)']);

  const addOwnerData1 = addOwnerInterface.encodeFunctionData('addOwner', [ownerAddresses[0]]);
  const addOwnerData2 = addOwnerInterface.encodeFunctionData('addOwner', [ownerAddresses[1]]);

  // clear the transaction batch
  await networkInstance.clearUserOpsFromBatch();

  // add transactions to the batch
  let userOpsBatch = await networkInstance.addUserOpsToBatch({ to: address, data: addOwnerData1 });
  userOpsBatch = await networkInstance.addUserOpsToBatch({ to: address, data: addOwnerData2 });


  console.log('transactions: ', userOpsBatch);

  // sign transactions added to the batch
  const op = await networkInstance.estimate();
  console.log('Estimated UserOp:', op);

  // sign the userOps and sending to the bundler...
  const uoHash = await networkInstance.send(op);
  console.log(`UserOpHash: ${uoHash}`);

  // get transaction hash...
  console.log('Waiting for transaction...');
  let userOpsReceipt = null;
  const timeout = Date.now() + 60000; // 1 minute timeout
  while (userOpsReceipt == null && Date.now() < timeout) {
    await sleep(2);
    userOpsReceipt = await networkInstance.getUserOpReceipt(uoHash);
  }
  console.log('\x1b[33m%s\x1b[0m', `Transaction Receipt: `, userOpsReceipt);
}

main()
  .catch(console.error)
  .finally(() => process.exit());
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kanalabs.io/smart-wallet-sdk/mirai-sdk-the-evm-smart-wallet-and-paymaster/examples/add-owners.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
