Skip to content

Instantly share code, notes, and snippets.

@abdelghafour
Last active June 9, 2024 13:42
Show Gist options
  • Save abdelghafour/717101c42a706ab9c222b05c8d4e4674 to your computer and use it in GitHub Desktop.
Save abdelghafour/717101c42a706ab9c222b05c8d4e4674 to your computer and use it in GitHub Desktop.
Runestone Swapping

Swap TX

Build the swap TX

import axios from "axios";

const headers = { Authorization: MY_COMPANY_API_KEY };
const data = {
  fee: SUGGESTED_NETWORK_FEE_RATE,
  cardinal: {
    amount: BTC_AMOUNT,
    from: {
      value: FROM_BTC_ADDRESS,
      publicKey: FROM_BTC_PUBLIC_KEY,
    },
    to: {
      value: TO_BTC_ADDRESS,
      publicKey: TO_BTC_PUBLIC_KEY,
    },
  },
  runestone: {
    from: {
      utxo: {
        id: RUNESTONE_UTXO_TXID,
        sequence: RUNESTONE_UTXO_INDEX,
      },
      name: THE.RUNE.NAME,
      id: X:Y,
      value: FROM_RUNESTONE_ADDRESS,
      publicKey: FROM_RUNESTONE_PUBLIC_KEY,
    },
    to: {
      value: TO_RUNESTONE_ADDRESS,
      publicKey: TO_RUNESTONE_PUBLIC_KEY,
    },
  },
  product: {
    id: PRODUCT_ID,
  },
};

const { data: escrow } = await axios.post(
  `${DEEP_LAKE_REST_API_URL}/flows/execute`,
  { data },
  { headers }
);

Logs:

  • Audit trails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment