> For the complete documentation index, see [llms.txt](https://docs.epochprotocol.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.epochprotocol.xyz/epoch-docs-v2-latest/use-epoch-sdk/intent-automation-module/examples/how-to-initialise-the-epoch-sdk.md).

# How to Initialise the Epoch SDK

## Simple Account API

```typescript
import { useEffect, useState } from "react";
import { HttpRpcClient, SimpleAccountAPI } from "@epoch-protocol/sdk";
import { useEthersProvider, useEthersSigner } from "~~/utils/scaffold-eth/common";

export const useBundler = () => {
  const ENTRY_POINT = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789";
  const FACTORY_ADDRESS = "0x4A4fC0bF39D191b5fcA7d4868C9F742B342a39c1";
  const bundlerUrl: string = process.env.BUNDLER_URL ?? "http://localhost:14337/80001";

  const [walletAPI, setWalletAPI] = useState<SimpleAccountAPI | null>(null);
  const [bundler, setBundler] = useState<HttpRpcClient | null>(null);

  const provider = useEthersProvider(); // Ethers Provider
  const signer = useEthersSigner(); // Ethers Signer

  useEffect(() => {
    (async () => {
      if (signer && provider) {
        const network = await provider.getNetwork();
x
        const walletAPIInstance = new SimpleAccountAPI({
          provider,
          entryPointAddress: ENTRY_POINT,
          owner: signer,
          factoryAddress: FACTORY_ADDRESS,
        });
        setWalletAPI(walletAPIInstance);

        const bundlerInstance = new HttpRpcClient(bundlerUrl, ENTRY_POINT, parseInt(network.chainId.toString()));
        setBundler(bundlerInstance);
      }
    })();
  }, [signer, provider, bundlerUrl]);

  return { walletAPI, bundler };
};

```

## SAFE Account API

```typescript
import { useEffect, useState } from "react";
import { HttpRpcClient, SafeAccountAPI } from "@epoch-protocol/sdk";
import { safeDefaultConfig } from "@epoch-protocol/sdk/dist/src/SafeDefaultConfig";
import { useEthersProvider, useEthersSigner } from "~~/utils/scaffold-eth/common";

export const useBundler = () => {
  const ENTRY_POINT = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789";
  const bundlerUrl: string = process.env.BUNDLER_URL ?? "http://localhost:14337/80001";

  const [walletAPI, setWalletAPI] = useState<SafeAccountAPI | null>(null);
  const [bundler, setBundler] = useState<HttpRpcClient | null>(null);

  const provider = useEthersProvider();
  const signer = useEthersSigner();

  useEffect(() => {
    (async () => {
      if (signer && provider) {
        const network = await provider.getNetwork();

        const walletAPIInstance = new SafeAccountAPI({
          provider,
          entryPointAddress: ENTRY_POINT,
          owner: signer,
          safeConfig: safeDefaultConfig[network.chainId],
          salt: safeDefaultConfig[network.chainId].salt,
        });
        setWalletAPI(walletAPIInstance);

        const bundlerInstance = new HttpRpcClient(bundlerUrl, ENTRY_POINT, parseInt(network.chainId.toString()));
        setBundler(bundlerInstance);
      }
    })();
  }, [signer, provider, bundlerUrl]);

  return { walletAPI, bundler };
};

```

Note - The Address in the above examples are for Polygon Mumbai


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.epochprotocol.xyz/epoch-docs-v2-latest/use-epoch-sdk/intent-automation-module/examples/how-to-initialise-the-epoch-sdk.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.
