> ## Documentation Index
> Fetch the complete documentation index at: https://etherspot.fyi/llms.txt
> Use this file to discover all available pages before exploring further.

# Etherspot Prime on Flare

> An introduction to Account Abstraction on Flare using the Etherspot Prime SDK

On this page we'll run through some introductory code on getting
set up with using Etherspot Prime on Flare.

## Installing packages

<Info>
  **Prerequisite** You should have installed Node.js (version 18.10.0 or
  higher).
</Info>

Install Etherspot Prime SDK with this command

<CodeGroup>
  ```bash npm theme={null}
  npm i @etherspot/prime-sdk --save
  ```

  ```bash yarn theme={null}
  yarn add @etherspot/prime-sdk
  ```
</CodeGroup>

## A look into the code

### Importing the SDK

```javascript theme={null}
  import { PrimeSdk } from '@etherspot/prime-sdk';
```

### Getting the smart account address

If you're unsure about the difference between key based accounts and smart contract
accounts, [please take a look at this page](/account-abstraction/eoa-vs-scw)

In this example we simply create a key based wallet with ethers.js like so:

```javascript theme={null}
const randomWallet = ethers.Wallet.createRandom();
setEoaPrivateKey(randomWallet.privateKey);
```

Then we use this key based wallet to instantiate the SDK on Coston2 and get the wallet address.

```javascript theme={null}
const primeSdk = new PrimeSdk({ privateKey: privateKey}, { chainId: 114, bundlerProvider: new EtherspotBundler(114, bundlerApiKey) });
const address: string = await primeSdk.getCounterFactualAddress();
console.log(address);
```

### Sending funds to another address

Now that we have a smart contract account on Coston2, we can fund
it using [Flare's offical faucet.](https://coston2-faucet.towolabs.com/)

Once we have funds on our account ([you can check this here](https://coston2-explorer.flare.network/))
we can try a simple send operation. This can be done through creating a sendFunds function like so:

We'll want to save **destinationAddress** and **amount** in some input field within the dapp.

```typescript theme={null}
const sendFunds = async () => {

    const primeSdk = new PrimeSdk({ privateKey: eoaPrivateKey}, { chainId: 114, bundlerProvider: new EtherspotBundler(114, bundlerApiKey) });
    // clear the transaction batch
    await  primeSdk.clearUserOpsFromBatch();

    // add transactions to the batch
    const transactionBatch = await primeSdk.addUserOpsToBatch({to: destinationAddress, value: ethers.utils.parseEther(destinationAddress)});

    // estimate transactions added to the batch and get the fee data for the UserOp
    const op = await primeSdk.estimate();

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

### Next steps

For next steps you can look at [functions](/prime-sdk/functions) or [examples](/prime-sdk/examples/intro)
to tailor the dapp to what you're trying to achieve.
