SafeSwap
Open SafeSwap
  • 👋Introduction to SafeSwap
  • Learn
    • 🤔How SafeSwap Works
    • 🪙SHA Token
    • ⛽Fee Structure
    • 💰Fee Distribution
    • 👑SafeNodes
    • 📚Glossary
  • User Guides
    • 🔄Swap Tokens
    • 📊Token Dashboard
  • Technical
    • ⚛️Cross-Chain Atomic Swaps
    • 🔐HTLC
    • 🛡️Security Measures
    • ⛓️Supported Blockchains
    • 👝Supported Wallets
    • 🕵️Audits
  • Builders
    • 🌍Hello World!
    • 🏗️Cross-Chain Use Cases
    • 🖥️Token Listing
    • 👨‍💻Whitelabel Integration
    • 📖API Integration Guide
      • Prerequisites
      • What is a Swap?
      • Perform a Swap
        • Initiate a Swap
        • Send Fees
        • Create the Swap in API
        • Wait/Poll for the Swap
        • Complete the Swap
        • Cancel/Refund
      • Smart Contract Details
      • Our Swap Addresses
      • API Details
  • About
    • Safe Haven
    • SafeTech
    • Support
Powered by GitBook
On this page
  • Find the Current Fees
  • Example
  1. Builders
  2. API Integration Guide
  3. Perform a Swap

Send Fees

Fees cover our portion of the smart contract interactions

PreviousInitiate a SwapNextCreate the Swap in API

Last updated 1 year ago

Fees. To account for the costs of each blockchain, fees must be paid on both the original network and the destination network. This covers SafeSwap's portion of the smart contract interactions.

Find the Current Fees

SafeSwap has an API endpoint that will tell you what the fees need to be. Call this API and then have the user send these fees.

Important: The fees must be sent by the same user who made the Swap in the smart contract in .

Get the addresses for SAFESWAP_FEE_ADDRESS_... , they are the same as the SWAP_ADDRESSES

For Vechain: the fee is to be paid in VTHO, not VET.

Example

const apiResponse = await fetch(`${SWAP_API_URL}/gas-estimate?sourceChain=VECHAIN&targetChain=ETHEREUM`, {
    headers: {
      'Content-Type': 'application/json',
      'X-API-KEY': 'MY_API_KEY'
    }
});

const fees = await apiResponse.json();

const originalChainFee = fees.sourceChain;
const destinationChainFee = fees.targetChain;

const originalTx = await signerOnOriginalChain.sendTransaction({to: SAFESWAP_FEE_ADDRESS_VECHAIN, value: originalChainFee})
const destinationTx = await signerOnDestinationChain.sendTransaction({to: SAFESWAP_FEE_ADDRESS_ETHEREUM, value: destinationChainFee})

const originalFeeTxId = originalTx.hash;
const destinationFeeTxId = destinationTx.hash;
📖
Initiate a Swap
here