🎹Sample Transactions

Sample transactions for all types of transactions in basic API

Overview

Here are some samples of the transaction object that is created in swap method. Rango currently returns 6 different types of transactions based on the blockchain that the transaction is happening on. This includes:

  • EVM: For all EVM-based blockchains, including Ethereum, Polygon, Avalanche, etc.

  • COSMOS: For all the cosmos-based networks, including the Cosmos itself, Osmosis, Akash, Thorchain, Maya and etc.

  • TRANSFER: For UTXO blockchains, including Bitcoin, Litecoin, Doge, etc.

  • SOLANA: For Solana transactions.

  • TRON: For Tron Transactions.

  • STARKNET: For Starknet transactions.

Let's see some examples here.

EVM Sample Transaction: (Test)

Here is the structure of an EVM transaction in the code below.

If the user does not have a sufficient approval amount for the transaction, the data for the approval transaction will be included in the approveData and approveTo fields. In this case, the user needs to sign the approval transaction first, ensure he has enough approval, and then signs the main transaction. However, if the approveData and approveTo fields are null, it indicates that the user already has enough approval for this quote and can directly sign the main transaction.

For the gas price of the transaction, if the blockchain supports the new versions of gas price, such as maxPriorityFeePerGas and maxFeePerGas, these fields will be populated. However, for blockchains that have not yet updated their gas model, the gas price will be set in the gasPrice field as before. You can check the list of all chains that support the new gas price versions in the meta or blockchains methods. (There is an enableGasV2 field in the response body, included for each blockchain.)

"tx": {
  // This field equals to EVM for all EVM Transactions
  "type": "EVM",
  
  // The blockchain that this transaction is going to run in
  "blockChain": {      
    "name": "POLYGON",
    "defaultDecimals": 18,
    "addressPatterns": [
      "^(0x)[0-9A-Fa-f]{40}$"
    ],
    "feeAssets": [
      {
        "blockchain": "POLYGON",
        "symbol": "MATIC",
        "address": null
      }
    ],
    "type": "EVM",
    "chainId": "137"
  },
  
  // The source wallet address, can be null
  "from": "0xeb2629a2734e272bcc07bda959863f316f4bd4cf",
  
  // Address of dex/bridge smart contract that is going to be called
  // It's usually rango contract address
  "txTo": "0x69460570c93f9DE5E2edbC3052bf10125f0Ca22d",
  
  // Address of source token erc20 contract for increasing approve amount
  "approveTo": null,
  
  // The data of approve transaction (null value means no approve needed)
  "approveData": null,
  
  // The data of main transaction, it can be null in case of native token transfer
  "txData": "0x0b320d9500000000000000000000000000000000000000000000000000000000000000000000000000000000000000006626c47c00f1d87902fc13eecfac3ed06d5e8d8a00000000000000000000000000000000000000000000000566fb0f266083987400000000000000000000000000000000000000000000000004cc4f07028c678c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000034d8edb091aed6929f535b0f06407964e2b935cc000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000181a0615b7d0000000000000000000000000000000000000000000000000000000000007917000000000000000000000000000000000000000000000000054da24e2a77c01e000000000000000000000000000000000000000000000000000000000000034000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000f491e7b69e4244ad4002bc14e878a34207e38c29000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e47ff36ab50000000000000000000000000000000000000000000000078bed27ba3317dd2a00000000000000000000000000000000000000000000000000000000000000800000000000000000000000002a7813412b8da8d18ce56fe763b9eb264d8e28a80000000000000000000000000000000000000000000000000000000062b871de000000000000000000000000000000000000000000000000000000000000000200000000000000000000000021be370d5312f44cb42ce377bc9b8a0cef1a4c830000000000000000000000006626c47c00f1d87902fc13eecfac3ed06d5e8d8a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e0000000000000000000000004691937a7508860f876c9c0a2a617e7d9e945d4b000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00000000000000000000000000000000000000000000000001af7aa59c0e923100000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000062b875630000000000000000000000000000000000000000000000000000000000000001000000000000000000000000eb2629a2734e272bcc07bda959863f316f4bd4cf0000000000000000000000002702d89c1c8658b49c45dd460deebcc45faec03c00000000000000000000000000000000000000000000000000000000000002200000000000000000000000001f5aaeedaa649712ccca0af8b3af0a4721c58cd2000000000000000000000000cb2a1486bcec00242b8e1934d2cb6a8075da18d900000000000000000000000000000000000000000000000000000000000000020000000000000000000000004691937a7508860f876c9c0a2a617e7d9e945d4b000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000007e8a8b130272430008eca062419acd8b423d339d",
  
  // The amount of transaction in case of native token transfer
  "value": "0x57115007b8d87c01e",
  
  // The suggested gas limit for this transaction
  "gasLimit": "0x9eb10",
  
  // The suggested gas price for this transaction
  "gasPrice": null, // e.g. 3308471992
  
  // Recommended max priority fee per gas for this transaction
  // Used only for blockchains with enableGasV2 = true (in meta endpoint)
  "maxPriorityFeePerGas": "46350100970",

  // Suggested max fee per gas for this transaction (max value for BaseGasPrice + PriorityGasPrice)
  // Used only for blockchains with enableGasV2 = true (in meta endpoint)
  "maxFeePerGas": "46350100971"
}

COSMOS Sample Transaction:

For Cosmos based blockchains, we have two type of transactions based on signType field: AMINO and DIRECT.

Cosmos Amino Sample Transaction: (Test)

"tx": {
  // This field equals to COSMOS for all COSMOS Transactions
  "type": "COSMOS",

  // Source wallet address for this transaction
  "fromWalletAddress": "osmo1unf2rcytjxfpz8x8ar63h4qeftadptg5t0nqcl",

  // The blockchain that this transaction is going to run in
  "blockChain": "OSMOSIS",

  // A real cosmos message, most fields of this object should be directly passed
  // to wallet for signing by user, the important part is msgs field that contains
  // all the cosmos actions that should be performed.
  "data": {
      "chainId": "osmosis-1",
      "account_number": 102721,
      "sequence": "686",
      "msgs": [
        {
          "type": "osmosis/gamm/swap-exact-amount-in",
          "value": {
            "sender": "osmo1unf2rcytjxfpz8x8ar63h4qeftadptg5t0nqcl",
            "routes": [
              {
                "pool_id": "5",
                "token_out_denom": "ibc/9712DBB13B9631EDFA9BF61B55F1B2D290B2ADB67E3A4EB3A875F3B6081B3B84"
              },
              {
                "pool_id": "6",
                "token_out_denom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"
              }
            ],
            "token_in": {
              "denom": "uosmo",
              "amount": "1000000"
            },
            "token_out_min_amount": "49999"
          }
        }
      ],
      "protoMsgs": [
        {
          "type_url": "/osmosis.gamm.v1beta1.MsgSwapExactAmountIn",
          "value": [
            10,
            43,
            // ...
          ]
        }
      ],
      "memo": "",
      "source": null,
      "fee": {
        "gas": "900000",
        "amount": [
          {
            "denom": "uosmo",
            "amount": "22500"
          }
        ]
      },
      // Sign type, could be AMINO or DIRECT
      "signType": "AMINO",
      "rpcUrl": "https://osmosis-rpc.polkachu.com"
    },
    
    // @deprecated An alternative to CosmosMessage object for the cosmos wallets 
    // that do not support generic Cosmos messages 
    "rawTransfer": null
  }
}

Cosmos Direct Sample Transaction: (Test)

This type is only used in limited swappers like WYNDDex (and Juno Blockchain) and we are going to deprecate support for Cosmos Direct transaction types whenever possible. You could sign this type of transactions using Stargate Client library.

"tx": {
  // This field equals to COSMOS for all COSMOS Transactions
  "type": "COSMOS",

  // Source wallet address for this transaction
  "fromWalletAddress": "juno1unf2rcytjxfpz8x8ar63h4qeftadptg54xrtf3",
  "blockChain": "JUNO",
  "data": {
    "chainId": "juno-1",
    "account_number": 125507,
    "sequence": "309",
    "msgs": [
      {
        "typeUrl": "/cosmwasm.wasm.v1.MsgExecuteContract",
        "value": {
          "sender": "juno1unf2rcytjxfpz8x8ar63h4qeftadptg54xrtf3",
          "contract": "juno1pctfpv9k03v0ff538pz8kkw5ujlptntzkwjg6c0lrtqv87s9k28qdtl50w",
          "msg": "eyJleGVjdXRlX3N3YXBfb3BlcmF0aW9ucyI6eyJvcGVyYXRpb25zIjpbeyJ3eW5kZXhfc3dhcCI6eyJhc2tfYXNzZXRfaW5mbyI6eyJuYXRpdmUiOiJpYmMvQzRDRkY0NkZENkRFMzVDQTRDRjRDRTAzMUU2NDNDOEZEQzlCQTRCOTlBRTU5OEU5QjBFRDk4RkUzQTIzMTlGOSJ9LCJvZmZlcl9hc3NldF9pbmZvIjp7Im5hdGl2ZSI6InVqdW5vIn19fV0sIm1heF9zcHJlYWQiOiIwLjAxIn19",
          "funds": [
            {
              "denom": "ujuno",
              "amount": "1000000"
            }
          ]
        }
      }
    ],
    "protoMsgs": [],
    "memo": "",
    "source": null,
    "fee": {
      "gas": "1000000",
      "amount": [
        {
          "denom": "ujuno",
          "amount": "2500"
        }
      ]
    },
    // Sign type, could be AMINO or DIRECT
    "signType": "DIRECT",
    "rpcUrl": "https://rpc-juno.itastakers.com:443/"
  },

  // @deprecated An alternative to CosmosMessage object for the cosmos wallets 
  "rawTransfer": null
}

Transfer Sample Transaction: (Test)

Here is the structure of an UTXO (Transfer) transaction:

"tx": {
  // This field equals to TRANSFER for all UTXO Transactions
  "type": "TRANSFER",

  // The method that should be passed to wallet including deposit, transfer
  "method": "transfer",

  // Source wallet address that can sign this transaction
  "fromWalletAddress": "qruy9zr8x9k335pkvqpfas3jsjfesq5gzu4nreyn4j",

  // Destination wallet address that the fund should be sent to
  "recipientAddress": "qzumtx6ufk3qu92slcsg5ajehujehzcquydmhaq0eh",

  // The memo of transaction, can be null
  "memo": "=:ETH.ETH:0x6f33bb1763eebead07cf8815a62fcd7b30311fa3:1080176077:rg:0",

  // The machine-readable amount of transaction
  "amount": "10000000000",

  // The decimals of the asset
  "decimals": 8,

  // An asset with its ticker
  "asset": {
    "blockchain": "BCH",
    "symbol": "BCH",
    "address": null,
    "ticker": "BCH"
  }
}

Tron Sample Transaction: (Test)

Here is the structure of a Tron transaction. Similar to EVM transactions, if user doesn't have enough approval for this quote, he needs to sign approve transaction first based on approve_payload, approve_raw_data, and approve_raw_data_hex fields and then sign the main transaction.

"tx": {
  // This field equals to TRON for all TRON Transactions
  "type": "TRON",
  // Transaction blockchain
  "blockChain": {
    "name": "TRON",
    "defaultDecimals": 18,
    "addressPatterns": [
      "^T[1-9A-HJ-NP-Za-km-z]{33}$"
    ],
    "feeAssets": [
      {
        "blockchain": "TRON",
        "symbol": "TRX",
        "address": null
      }
    ],
    "type": "TRON",
    "chainId": "728126428"
  },
  // The data of smart contract call
  "raw_data": {
    "contract": [
      {
        "parameter": {
          "value": {
            "data": "b24ebddb000000000000000000000000000000000000000000000000000000000001160500000000000000000000000000000000000000000000000000000189ea5a08a000000000000000000000000000000000000000000000000000000000000f4240",
            "owner_address": "414a9bbc3fe169c752a08de9c7becfb4921034ae4a",
            "contract_address": "41a2726afbecbd8e936000ed684cef5e2f5cf43008",
            "call_value": 1000000
          },
          "type_url": "type.googleapis.com/protocol.TriggerSmartContract"
        },
        "type": "TriggerSmartContract"
      }
    ],
    "ref_block_bytes": "1091",
    "ref_block_hash": "5310b46b57c59d0d",
    "expiration": 1691853975000,
    "fee_limit": 1500000000,
    "timestamp": 1691853916537
  },
  "approve_raw_data": null,
  "raw_data_hex": "0a02109122085310b46b57c59d0d40d8dbebd29e315ad301081f12ce010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e74726163741298010a15414a9bbc3fe169c752a08de9c7becfb4921034ae4a121541a2726afbecbd8e936000ed684cef5e2f5cf4300818c0843d2264b24ebddb000000000000000000000000000000000000000000000000000000000001160500000000000000000000000000000000000000000000000000000189ea5a08a000000000000000000000000000000000000000000000000000000000000f424070f992e8d29e31900180dea0cb05",
  "approve_raw_data_hex": null,
  "__payload__": {
    "call_value": 1000000,
    "contract_address": "41a2726afbecbd8e936000ed684cef5e2f5cf43008",
    "fee_limit": 1500000000,
    "function_selector": "trxToTokenSwapInput(uint256,uint256,uint256)",
    "owner_address": "414a9bbc3fe169c752a08de9c7becfb4921034ae4a",
    "parameter": "000000000000000000000000000000000000000000000000000000000001160500000000000000000000000000000000000000000000000000000189ea5a08a000000000000000000000000000000000000000000000000000000000000f4240",
    "chainType": 0
  },
  "approve_payload": null,
  "txID": "45a6390a1c1fe80832bd654cbb08bd5c6e804f4fe7f0fc4014421b84280e044c",
  "approveTxID": null,
  "visible": false,
  "approveVisible": null
}

Starknet Sample Transaction: (Test)

Here is the structure of a Starknet transaction. Similar to EVM transactions, if user doesn't have enough approval for this quote, he needs to sign approve transaction first based on approveCalls field first and then sign the main transaction.

"tx": {
  // This field equals to STARKNET for all STARKNET Transactions
  "type": "STARKNET",

  // Transaction blockchain
  "blockChain": "STARKNET",

  // List of calldata to sign a multiple transaction
  "calls": [
    {
      "contractAddress": "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
      "entrypoint": "approve",
      "calldata": [
        "0x07a6f98c03379b9513ca84cca1373ff452a7462a3b61598f0af5bb27ad7f76d1",
        "0x000000000000000000000000000f4240",
        "0x00000000000000000000000000000000"
      ]
    },
    {
      "contractAddress": "0x07a6f98c03379b9513ca84cca1373ff452a7462a3b61598f0af5bb27ad7f76d1",
      "entrypoint": "swapExactTokensForTokens",
      "calldata": [
        "0x000000000000000000000000000f4240",
        "0x00000000000000000000000000000000",
        "0x00000000000000000000000065434224",
        "0x00000000000000000000000000000000",
        "2",
        "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
        "0xda114221cb83fa859dbdb4c44beeaa0bb37c7537ad5ae66fe5e0efd20e6eb3",
        "0x473ab17973104e37d341d8127e1b109e7960443a7b08abb63a76e1e3e405067",
        "1691858292"
      ]
    }
  ],

  // List of approves calldata if needed
  "approveCalls": null,

  // Max fee for the transaction
  "maxFee": null
}

Solana Sample Transaction: (Test)

Base64 Encoding

Remember to broadcast the signed transaction to Solana RPCs with base64 encoding. The base58 encoding is deprecated, but it is still the default method in Solana docs.

Versioned vs Legacy

All supported routes for Solana are VERSIONED transactions except a special case of converting SOL to WSOL or vice versa via Solana Wrapper. (which you can ignore it.)

"tx": {
     // This field equals to SOLANA for all SOLANA Transactions
    "type": "SOLANA",
    
    // Transaction blockchain
    "blockChain": "SOLANA",
    
    // Wallet address of transaction initiator
    "from": "3HsNMDtxPRUzwLpDJemmNVbasm11Ei5CGGCjktgHh27F",
    
    // Transaction identifier in case of retry
    "identifier": "Swap",
    
    // List of instructions
    "instructions": [ ],

    // Recent blockHash. Nullable. Filled only if message is already partially signed
    "recentBlockhash": null,
    
    // List of signatures. Filled only if message is already partially signed
    "signatures": [ ],
    
    // When serialized message appears, there is no need for other fields and you just sign and send it
    "serializedMessage": [1, 0, 95, 96, ..., 1, 253], 
    
    // Could be LEGACY or VERSIONED
    "txType": "VERSIONED"
  }

Last updated