# Quickstart (/onramp/smart-routing-address/quickstart)

> For the complete documentation index, see [llms.txt](/llms.txt)



## Installation [#installation]

<Tabs items="[&#x22;npm&#x22;,&#x22;yarn&#x22;,&#x22;pnpm&#x22;,&#x22;bun&#x22;]">
  <Tab value="npm">
    ```bash
    npm i @zerodev/smart-routing-address
    ```
  </Tab>

  <Tab value="yarn">
    ```bash
    yarn add @zerodev/smart-routing-address
    ```
  </Tab>

  <Tab value="pnpm">
    ```bash
    pnpm i @zerodev/smart-routing-address
    ```
  </Tab>

  <Tab value="bun">
    ```bash
    bun add @zerodev/smart-routing-address
    ```
  </Tab>
</Tabs>

## Usage [#usage]

Smart Routing Address has a beautifully simple API: just `createSmartRoutingAddress` and then send funds to it. That's really it.

We recommend that you take a look at [our code example](https://github.com/zerodevapp/smart-routing-address-example) (even better if you try running it) as you follow along the docs.

### Creating a smart routing address [#creating-a-smart-routing-address]

In the following example, we are going to create a smart routing address that, when receiving funds on any chain, will transfer the funds to a specific address on Base. This is helpful when, for instance, you want to create a deposit address for your user, so that they can send funds to the address on any chain (possibly from a CEX), and then they will receive funds in their wallet on the chain that your app runs on.

First import some types and functions:

```tsx
import {
  createSmartRoutingAddress,
  createCall,
  FLEX,
} from "@zerodev/smart-routing-address";
```

Then set up some values (explained below):

```tsx
// Replace with your own address
const owner = "0x244b33858733aab5307B0919D31f73878cAF617B";

const destChain = base;
const slippage = 5000;

// This is the call that will be executed on the destination chain
const call = createCall({
  target: FLEX.TOKEN_ADDRESS, // any tokens
  value: 0n,
  abi: erc20Abi,
  functionName: "transfer",
  args: [owner, FLEX.AMOUNT], // any amount
});
```

Finally, create a smart routing address:

```tsx
const { smartRoutingAddress } = await createSmartRoutingAddress({
  owner,
  destChain,
  // Source tokens (any ERC20 on arbitrum, ETH on mainnet, USDC on optimism)
  srcTokens: [
    {
      tokenType: "ERC20",
      chain: arbitrum,
    },
    {
      tokenType: "NATIVE",
      chain: mainnet,
    },
    {
      tokenType: "USDC",
      chain: optimism,
    },
  ],
  actions: {
    USDC: {
      action: [call],
      fallBack: [],
    },
  },
  slippage,
});
```

The options are:

* `owner` is an address that is authorized to recover funds from the smart routing address, in case the smart routing address fails to execute the target action for whatever reason. Typically you would set this to your user's EOA wallet, but you could also set it to your own address if you want to recover funds for users.

* `destChain` is the chain on which the `actions` are supposed to happen. This is presumably the chain that your app runs on.

* `srcTokens` is a list of tokens that the smart routing address should be able to receive. Only tokens listed in `srcTokens` will trigger actions on the destination. The other tokens sent to the address will have to be manually recovered by the `owner`.

* `actions` is a map that records which action will be triggered by which token. In the example above, we specified an action that will be triggered when the smart routing address receives `USDC`.

* `slippage` is the *maximum* slippage that the user can expect. `slippage` is an integer, where 1 is equal to 0.01% (so 100 would mean 1% slippage). You can skip this param if you are unsure what to set, and the SDK will estimate a reasonable slippage based on your other settings.

Once you have created a smart routing address, you can send tokens to it on any of the chains specified in `srcTokens`, and the `actions` will happen on the `destChain`. It's really that simple.
