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

# Introduction to Arka

## Intro

Arka is Etherspot's implementation of a [paymaster](https://github.com/eth-infinitism/account-abstraction/blob/ver0.6.0/contracts/interfaces/IPaymaster.sol).
This means we can let the user pay with ERC-20 tokens, or pay for specific user transactions ourselves.

## Using Arka

When estimating a transaction with the SDK we can pass in paymaster values and choose one of three modes:

1. sponsor
2. erc20
3. multitoken

For either mode we need to pass the parameter 'url' inside estimate fn of the primeSdk in order for the sdk to know that the userOp needs to be sponsored. In this url we include the **url of
the Arka instance**, the [**apiKey**](/prime-sdk/api-key-portal), and the [**chainId**](prime-sdk/chains-supported).

> **Note:** The 'useVp' parameter is passed so that the system uses the deployed Verifying Paymaster that you deployed using developer dashboard if not it will error out as 'Paymaster not deployed' message.
> And by default, the value is false and will use EtherspotPaymaster contract which is only for EntryPoint v6

We can create the arguments like so:

```javascript theme={null}
const ARKA_API_KEY = 'etherspot_public_key'; //  replace with your arka api key
const ARKA_URL = 'https://rpc.etherspot.io/paymaster/';
const CHAIN_ID = 137;
const queryString = `?apiKey=${ARKA_API_KEY}&chainId=${CHAIN_ID}&useVp=true`;
```

## mode: 'sponsor'

This works by having Arka pay for the transaction fee.

```javascript theme={null}
await primeSdk.estimate({ url: `${ARKA_URL}${queryString}`,
context: { mode: 'sponsor' } });
```

### validUntil / validAfter

**validUntil and validAfter are relevant only with mode: sponsor transactions and not for mode: erc20.**

validUntil and validAfter are optional defaults to 10 mins of expiry from send call and should be passed in terms of milliseconds.
For example purpose, the valid is fixed as expiring in 100 mins once the paymaster data is generated.

```javascript theme={null}
await primeSdk.estimate({ url: `${ARKA_URL}${queryString}`, 
context: { mode: 'sponsor', validAfter: new Date().valueOf(), validUntil: new Date().valueOf() + 6000000 } });
```

## mode: 'erc20'

This works by having the gas fee paid with whatever token is specified.

```javascript theme={null}
await primeSdk.estimate({ url: `${ARKA_URL}${queryString}`,
context: { token: "USDC", mode: 'erc20' } });
```

## mode: 'multitoken'

This works by having the gas fees paid with whatever token is specified but unlike erc20, each chain would have the same paymaster address across different tokens supported on that contract.

```javascript theme={null}
await primeSdk.estimate({ url: `${ARKA_URL}${queryString}`,
context: { token: "0x453478E2E0c846c069e544405d5877086960BEf2", mode: 'multitoken' } });
```

Please note that the above token is from Ancient8 testnet(28122024) which is available on `etherspot_public_key` apiKey. Request `0x453478E2E0c846c069e544405d5877086960BEf2` tokens if you unable to fetch it on [discord](https://discord.etherspot.io/)

Please [get in touch](https://discord.etherspot.io/) if you wish to get an api key for development.
