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

# DNA Send & Swap

Generate deep links to the DNA app for quick actions like Swap and Send.

[DNA](https://worldcoin.org/ecosystem/app_8e407cfbae7ae51c19b07faff837aeeb) now supports a **Quick Action** to deeplink directly
into the wallet interface, allowing users to perform specific actions like sending tokens or swapping assets with predefined parameters.

<div className="flex justify-between items-start">
  <div className="flex-1">
    <h3>Parameters</h3>

    <ParamField path="tab" type="string" required>
      Supports deep linking to the `swap` and `send` tabs.
    </ParamField>

    <ParamField path="fromToken" type="string">
      The contract address of the token being sent (`fromToken`).
    </ParamField>

    <ParamField path="toToken" type="string">
      The contract address of the token being received (`toToken`). This is used
      in **swap** actions.
    </ParamField>

    <ParamField path="recipientAddress or username" type="string">
      The recipient's wallet address or username for sending tokens.
    </ParamField>

    <ParamField path="amount" type="string">
      The amount of the `fromToken` to be sent, specified in its **base unit** .
    </ParamField>

    <ParamField path="sourceAppId" type="string">
      The application ID of the source app initiating the deeplink.
    </ParamField>

    <ParamField path="sourceDeeplinkPath" type="string">
      A deeplink path from the source application, which will be
      **URL-encoded**.
    </ParamField>
  </div>

  <Tabs>
    <Tab title="Send">
      <img src="https://mintcdn.com/tfh/vNgKkjbn9HQ46Vw7/images/docs/mini-apps/quick-actions/dna-qa-send.png?fit=max&auto=format&n=vNgKkjbn9HQ46Vw7&q=85&s=da6a0d57d54de7331c1956f4f981d9e2" alt="Send Screen" className="m-auto block" width="260" style={{ maxWidth: "260px", height: "auto" }} data-path="images/docs/mini-apps/quick-actions/dna-qa-send.png" />
    </Tab>

    <Tab title="Swap">
      <img src="https://mintcdn.com/tfh/vNgKkjbn9HQ46Vw7/images/docs/mini-apps/quick-actions/dna-qa-swap.png?fit=max&auto=format&n=vNgKkjbn9HQ46Vw7&q=85&s=b590b3df3589bcebff653dd783ec32e7" alt="Swap Screen" className="m-auto block" width="260" style={{ maxWidth: "260px", height: "auto" }} data-path="images/docs/mini-apps/quick-actions/dna-qa-swap.png" />
    </Tab>
  </Tabs>
</div>

## Helper Function

```tsx theme={null}
const DNA_APP_ID = "app_8e407cfbae7ae51c19b07faff837aeeb";

function getDNADeeplinkUrl({
  tab,
  fromToken,
  toToken,
  recipientAddress,
  amount,
  sourceAppId,
  sourceDeeplinkPath,
}: {
  tab: "swap" | "send";
  fromToken?: string;
  toToken?: string;
  recipientAddress?: string;
  amount?: string;
  sourceAppId?: string;
  sourceDeeplinkPath?: string;
}) {
  let path = `/wallet?tab=${tab}`;

  if (fromToken) {
    path += `&fromToken=${fromToken}`;
    if (amount) {
      path += `&amount=${amount}`;
    }
  }

  if (toToken) {
    path += `&toToken=${toToken}`;
  }

  if (recipientAddress) {
    path += `&recipientAddress=${recipientAddress}`;
  }

  if (sourceAppId) {
    path += `&sourceAppId=${sourceAppId}`;
  }

  if (sourceDeeplinkPath) {
    path += `&sourceDeeplinkPath=${encodeURIComponent(sourceDeeplinkPath)}`;
  }

  const encodedPath = encodeURIComponent(path);
  return `https://worldcoin.org/mini-app?app_id=${DNA_APP_ID}&path=${encodedPath}`;
}
```

## **Returns**

A string representing the complete deeplink URL to the DNA application with the specified parameters.

## **Example Usage**

```typescript theme={null}
const deeplinkUrl = getDNADeeplinkUrl({
  fromToken: "0x79A02482A880bCE3F13e09Da970dC34db4CD24d1",
  toToken: "0x4200000000000000000000000000000000000006",
  recipientAddress: "0xRecipientAddressHere",
  amount: "1235",
  sourceAppId: "app_a4f7f3e62c1de0b9490a5260cb390b56",
  sourceDeeplinkPath: "/path",
});
console.log(deeplinkUrl);
```

## **Generated Deeplink URL:**

```bash theme={null}
https://worldcoin.org/mini-app?app_id=app_8e407cfbae7ae51c19b07faff837aeeb&path=%2Fwallet%3Ftab%3Dsend%26fromToken%3D0x79A02482A880bCE3F13e09Da970dC34db4CD24d1%26amount%3D1234500%26toToken%3D0x4200000000000000000000000000000000000006%26recipientAddress%3D0xRecipientAddressHere%26sourceAppId%3Dapp_a4f7f3e62c1de0b9490a5260cb390b56%26sourceDeeplinkPath%3D%252Fsome%252Fpath
```

## **Note**

* Ensure that the **amount** is specified in the unit of the fromToken (e.g., wei for Ethereum-based tokens).
* The **sourceDeeplinkPath** is URL-encoded to ensure it is correctly interpreted when the deeplink is accessed.
* The **DNA\_APP\_ID** should be defined in your environment to match the application ID assigned to your DNA instance.
* If the tab is **Send**, it is necessary/recommended to provide **fromToken**, **amount**, and **the recipient's address or username** *(toToken is not required)*.
* If the tab is **Swap**, it is necessary/recommended to provide **fromToken**, **toToken**, and **amount** *(in base unit)*.

This function facilitates the creation of deeplink URLs that can be used to direct users seamlessly into specific actions within the DNA application, enhancing the user experience by pre-filling transaction details.
