Butter Network
Github
  • 🌈About Butter Network
  • 🔥ZK Light Client
    • Understanding Light Client
    • Refactored ZK Light Client
  • 🔥Omnichain Development
    • Omnichain Isomorphism
    • More Possibilities
  • 🌈Butter Omnichain Messaging Integration
    • Introduction
    • Integration Guide
      • Message
      • Message with Ton
      • CALLDATA
      • Message And Relay
    • Contract Interface
    • Fee
    • Deployed Contracts
    • 👨‍💻API for Omnichain Message
      • GET Message History by Source Address
      • GET Message Info by Id
      • GET Message Info by Source Hash
  • 🔥Butter Bridge Integration
    • Integration Guide
    • Contract Interface
    • Fee
    • Deployed Contracts
  • 💰Butter Swap Integration
    • Introduction
    • 🟢Integration Guide
      • Contract Interface
      • Fee
    • Deployed Contracts
      • v2.1
    • 👩‍💻API for Routing
      • Integration Guide
      • GET /route
      • GET /swap
      • GET /routeAndSwap
      • GET /supportedChainList
      • GET /findToken
      • 🔴Error Code List
    • 👨‍💻API for Swap Data
      • GET Swap History by Source Hash
      • GET Swap History by Source Address
      • GET Swap Info by Order ID
      • GET Supported Chain Detail List
      • GET Supported Token Detail List
  • 💰Butter Swap User Guide
    • 🫂User Guide
  • Butter Swap SDK
    • Install
    • Config SDK
    • Request Routes
    • Execute Route
    • Others
  • Butter Swap Widget
    • Usage
  • 📢Resources
    • 🏠Website
    • 🫂Telegram
    • 📄X
Powered by GitBook
On this page
  • Get Route Transactions
  • Execute Route
  1. Butter Swap SDK

Execute Route

We allow you to execute any on-chain or cross-chain swap and bridging transfer and a combination of both.

Get Route Transactions

Before execute a route, we need to request Rotue Transactions by generateSwapData:

const txn = await generateSwapData({
  hash: "0x123......", // hash from getRoutes
  slippage: "100",
  receiver: "0x123123...",
  from: "0x123123...",
});

Return data is

export interface RouteTxData {
  to: string;
  data: string;
  value: string;
  method?: string;
  chainId: string;
  args: {
    type: string;
    value: any;
  }[];
}

Execute Route

Then we can execure the route;

import { executeRoute } from "@butternetwork/sdk";
// Near
const hash = await executeRoute(txn);
// Other Chain
// const hash = await executeRoute(txn[0]);
  • Parameters

    • route: RouteTxData | RouteTxData[] the route transaction to be execure.

  • Return

    • Promise<string>: Resolves when execution is done or halted and rejects when it is failed.

PreviousRequest RoutesNextOthers

Last updated 4 months ago