Skip to main content
Use this Quick Action to deep link into the Swap interface with prefilled parameters.

Parameters

app_id
string
Target app id for the Swap quick action: app_6c5c5717c77abe83be8814c032c3a6f9.
path
string
Path inside the target app. Use ’/’ for Swap.
fromToken
string | 0x${string}
Token address for the “from” token.
toToken
string | 0x${string}
Token address for the “to” token.
amount
string
Amount of the from token in base token units.
sourceAppId
string
app_id of the app that uses this quick action.
sourceAppName
string
Name of the app that uses this quick action.
Swap Screen

Helper function

export interface ActionLinkProps {
  targetAppId: string; // app_6c5c5717c77abe83be8814c032c3a6f9 for Swap quick action
  path: string; // '/' for Swap quick action
  params: Record<string, string>;
}

const MAIN_ACTION_URL = "https://worldcoin.org/mini-app";

export function getActionLink({ targetAppId, path, params }: ActionLinkProps) {
  let fullPath = path;

  if (Object.keys(params).length > 0) {
    const paramParts = Object.entries(params).map(([key, value]) => {
      return `${key}=${value}`;
    });
    fullPath += `?${paramParts.join("&")}`;
  }

  const queryString = `${MAIN_ACTION_URL}?app_id=${targetAppId}&path=${encodeURIComponent(fullPath)}`;

  return queryString;
}

// Example usage
const link = getActionLink({
  targetAppId: "app_6c5c5717c77abe83be8814c032c3a6f9",
  path: "/",
  params: {
    fromToken: "0x2cFc85d8E48F8EAB294be644d9E25C3030863003",
    toToken: "0x4200000000000000000000000000000000000006",
    amount: "1234500",
    sourceAppId: "app_source1234567890abcdef",
    sourceAppName: "My%20App",
  },
});
console.log(link);
https://worldcoin.org/mini-app?app_id=app_6c5c5717c77abe83be8814c032c3a6f9&path=%2F%3FfromToken%3D0x2cFc85d8E48F8EAB294be644d9E25C3030863003
I