🎹Sample Transactions

Sample transactions for all types of transactions in main API

Overview

Here are some samples of the transaction object that is created in create transaction 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 lacks sufficient approval for the transaction, the create transaction method will respond with an approval transaction. (isApproval field is true in this case.) The user must first sign this approval transaction to ensure they have the necessary approval. Then, they should call the create transaction method again to obtain and sign the main transaction. The fields and schema for the approval and main transactions are identical.

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.)

"transaction": {
    "type": "EVM",
    "blockChain": "BSC",
    "isApprovalTx": true,
    "from": "0x7abac41d46857b0b6c4d67eb966b4a29ba69b4f3",
    "to": "0xe9e7cea3dedca5984780bafc599bd69add087d56",
    "data": "0x095ea7b300000000000000000000000069460570c93f9de5e2edbc3052bf10125f0ca22d000000000000000000000000000000000000000000000000000775f05a074000",
    "value": null,
    "gasLimit": "0x12284",
    "gasPrice": "1100000000",
    "maxPriorityFeePerGas": null,
    "maxFeePerGas": null,
    "nonce": null
}

Sample for non-approval:

"transaction": {
  "type": "EVM",
  "blockChain": "BSC",
  "isApprovalTx": false,
  "from": "0xccf3d872b01762aba74b41b1958a9a86ee8f34a2",
  "to": "0x69460570c93f9DE5E2edbC3052bf10125f0Ca22d",
  "data": "0xb17d0e6e000000000000000000000000000000002358d41a5a8f4afa87403e161e2955e900000000000000000000000055d398326f99059ff775485246999027b3197955000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000081fe9fae05d8094c0000000000000000000000000000000000000000000000000031fe30556285140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037f73c93f73fac000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000ccf3d872b01762aba74b41b1958a9a86ee8f34a3000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000001b81d678ffb9c0263b24a97847620c99d213eb140000000000000000000000001b81d678ffb9c0263b24a97847620c99d213eb1400000000000000000000000055d398326f99059ff775485246999027b31979550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000081fe9fae05d8094c00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000264ac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000190ff9d543500000000000000000000000000000000000000000000000081fe9fae05d8094c0000000000000000000000000000000000000000000000000037f4872b410e24000000000000000000000000000000000000000000000000000000000000002b55d398326f99059ff775485246999027b31979550001f4bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c0000000000000000000000000000000000000000000000000037f73c93f73fac00000000000000000000000069460570c93f9de5e2edbc3052bf10125f0ca22d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "value": null,
  "gasLimit": "0x91bc6",
  "gasPrice": "1100000000",
  "maxPriorityFeePerGas": null,
  "maxFeePerGas": null,
  "nonce": null
}

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)

{
  "type": "COSMOS",
  "fromWalletAddress": "osmo1unf2rcytjxfpz8x8ar63h4qeftadptg5t0nqcl",
  "blockChain": "OSMOSIS",
  "data": {
    "chainId": "osmosis-1",
    "account_number": 102721,
    "sequence": "892",
    "msgs": [
      {
        "type": "wasm/MsgExecuteContract",
        "value": {
          "sender": "osmo1unf2rcytjxfpz8x8ar63h4qeftadptg5t0nqcl",
          "contract": "osmo1clp46dz247hck0ns5jkv49hqzg8x0vh5hsx8yfvk6w87hnvc6hgs563ew3",
          "msg": {
            "swap_and_action": {
              "user_swap": {
                "swap_exact_asset_in": {
                  "swap_venue_name": "osmosis-poolmanager",
                  "operations": [
                    {
                      "pool": "1464",
                      "denom_in": "uosmo",
                      "denom_out": "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4"
                    },
                    {
                      "pool": "1838",
                      "denom_in": "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4",
                      "denom_out": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"
                    }
                  ]
                }
              },
              "min_asset": {
                "native": {
                  "denom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2",
                  "amount": "74944"
                }
              },
              "timeout_timestamp": 1722276105002000000,
              "post_swap_action": {
                "transfer": {
                  "to_address": "osmo1unf2rcytjxfpz8x8ar63h4qeftadptg5t0nqcl"
                }
              },
              "affiliates": []
            }
          },
          "funds": [
            {
              "denom": "uosmo",
              "amount": "1000000"
            }
          ]
        }
      }
    ],
    "protoMsgs": [
      {
        "type_url": "/cosmwasm.wasm.v1.MsgExecuteContract",
        "value": [
          10,
          43,
          111,
          // ...
        ]
      }
    ],
    "memo": "",
    "source": null,
    "fee": {
      "gas": "2000000",
      "amount": [
        {
          "denom": "uosmo",
          "amount": "50000"
        }
      ]
    },
    // 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 
  "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.

"transaction": {
  "type": "COSMOS",
  "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:

"transaction": {
  // 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, it can be either an approval transaction or a main transaction, depending on the isApproval field

{
  "type": "TRON",
  "blockChain": "TRON",
  "isApprovalTx": false,
  "raw_data": {
    "contract": [
      {
        "parameter": {
          "value": {
            "data": "b24ebddb000000000000000000000000000000000000000000000000000000000002091100000000000000000000000000000000000000000000000000000190ffaa951100000000000000000000000000000000000000000000000000000000000f4240",
            "owner_address": "413a51fc0bc19accbea62fac65bad2660bbcffd08a",
            "contract_address": "41a2726afbecbd8e936000ed684cef5e2f5cf43008",
            "call_value": 1000000
          },
          "type_url": "type.googleapis.com/protocol.TriggerSmartContract"
        },
        "type": "TriggerSmartContract"
      }
    ],
    "ref_block_bytes": "af01",
    "ref_block_hash": "e4752a1cdaf3e944",
    "expiration": 1722276345000,
    "fee_limit": 1500000000,
    "timestamp": 1722276287817
  },
  "raw_data_hex": "0a02af012208e4752a1cdaf3e94440a8e9adfd8f325ad301081f12ce010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e74726163741298010a15413a51fc0bc19accbea62fac65bad2660bbcffd08a121541a2726afbecbd8e936000ed684cef5e2f5cf4300818c0843d2264b24ebddb000000000000000000000000000000000000000000000000000000000002091100000000000000000000000000000000000000000000000000000190ffaa951100000000000000000000000000000000000000000000000000000000000f424070c9aaaafd8f32900180dea0cb05",
  "externalTxId": null,
  "__payload__": {
    "owner_address": "413a51fc0bc19accbea62fac65bad2660bbcffd08a",
    "call_value": 1000000,
    "contract_address": "41a2726afbecbd8e936000ed684cef5e2f5cf43008",
    "fee_limit": 1500000000,
    "function_selector": "trxToTokenSwapInput(uint256,uint256,uint256)",
    "parameter": "000000000000000000000000000000000000000000000000000000000002091100000000000000000000000000000000000000000000000000000190ffaa951100000000000000000000000000000000000000000000000000000000000f4240",
    "chainType": 0
  },
  "txID": "10d1428e0ccc8870b9334d73da2313cfaff29ec27930e68a6947ea8bb1d6b181",
  "visible": false
}

Starknet Sample Transaction: (Test)

Here is the structure of a Starknet transaction. Like EVM transactions, it can be either an approval transaction or a main transaction, depending on the isApproval field. Whenever possible, in Starknet, we batch the approval and main transactions into a single transaction using the calls array, as shown in the example below.

"transaction": {
    "type": "STARKNET",
    "blockChain": "STARKNET",
    "calls": [
        {
            "contractAddress": "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
            "entrypoint": "approve",
            "calldata": [
                "0x4270219d365d6b017231b52e92b3fb5d7c8378b05e9abc97724537a80e93b0f",
                "0x00000000000000000ddb6275b03a4000",
                "0x00000000000000000000000000000000"
            ]
        },
        {
            "contractAddress": "0x4270219d365d6b017231b52e92b3fb5d7c8378b05e9abc97724537a80e93b0f",
            "entrypoint": "multi_route_swap",
            "calldata": [
                "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
                "0xddb6275b03a4000",
                "0x0",
                // ...
            ]
        },
        {
            "contractAddress": "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
            "entrypoint": "transfer",
            "calldata": [
                "0x01d8b73b49d8cb653570929260e8e01033278d6840f706faa421f08b992f8083",
                "0x00000000000000000005543df729c000",
                "0x00000000000000000000000000000000"
            ]
        }
    ],
    "maxFee": null,
    "isApprovalTx": false,
    "spender": 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.)

"transaction": {
     // 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