Skip to main content
API Reference: Get Action Submitting transactions differs by source chain VM. Reference available transaction types here. Examples below demonstrate the swap process for each VM. VmId: evm, solana, alt-vm (any non-named VM - e.g., Bitcoin, Ripple).

Create a swap transaction

1

Configure the transaction request

The recipient should only be different from the sender if you are:
  1. Swapping across VMs that use incompatible key formats or cryptographic curves (e.g., EVM <> Solana)
  2. Sending funds to another address
This example prepares a swap from USDC on Base to USDT on Arbitrum. To transact across non-EVM networks, simply update the chainId and token fields to your desired pairs, no further customizations required.
2

Generate the transaction

Please visit the Get Action API reference for type definitions, including the ActionRequest and ActionResponse. This API endpoint will return a transaction object we will use to actually execute this transaction.

Broadcast on EVM

In this step, we will broadcast the transaction we generated above on Base. This method will work for any EVM chain. View the EVM transaction type here.
1

Import the recommended libraries

This example uses Wagmi; however, you can use your preferred provider. The transaction we’ll generate is compatible with any library.
2

Broadcast the transaction

Broadcast on Solana

Let’s assume we set Solana as the source chain in the actionRequest used to generate our transaction. Let’s see how we can broadcast it on Solana. View the Solana transaction type here.
1

Import the recommended libraries

We’ll use @solana/web3.js, which is the standard SDK for interacting with the Solana blockchain.
2

Broadcast the transaction

Broadcast on Alt VMs

Let’s assume we set Bitcoin as the source chain in the actionRequest used to generate our transaction. Let’s see how we can broadcast it on Bitcoin. View the alt VM transaction type here. Alt VM transactions are all deposits: the transaction will transfer funds from the sender to the to field specified in the AltVmTransaction response. This transfer triggers the swap transaction and funds will ultimately be delivered to the recipient.
1

Install recommended package

2

Import the recommended libraries

We’ll use bitcoinjs-lib to sign the Bitcoin transaction.
3

Broadcast the transaction

This example provides sample code to construct a Bitcoin transaction given the actionResponse transaction object and broadcast it to the network.

Broadcast on HyperCore

Let’s assume we set HyperCore as the source chain in the actionRequest used to generate our transaction. Let’s see how we can broadcast it on HyperCore. View the HyperCore transaction type here.
1

Install recommended package

2

Import the recommended libraries

We’ll use the HyperLiquid SDK for interacting with the HyperCore network.
3

Broadcast the transaction