Sample Transactions

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

  • EVM: This type supports all Ethereum-based blockchains, including Ethereum, BSC, Polygon, Fantom, Harmony, Avalanche, etc.

  • TRANSFER: This type is mostly used for UTXO blockchains, including BTC, LTC, BCH, DOGE, etc.

  • COSMOS: Rango uses this, as the name indicates, for all the cosmos-based networks, including the Cosmos itself, Sifchain, Osmosis, Sentinel, etc. + Thorchain/Terra and Binance Chain (BNB network)

  • SOLANA: For different types of Solana transactions.

Let's see some examples in each category.

EVM Transactions

Here is the structure of an EVM transaction:

"transaction": {
  // The blockchain of the wallet
  "blockChain": "BSC",
  
  // If true, this transaction wants the user to approve a smart contract
  // If a user signs an approval transaction, you should call checkApprove 
  // endpoint to make sure the approval is saved on the blockchain, and then call
  // createTransaction again to get the main transaction
  "isApprovalTx": false,
  
  // The signer wallet address
  "from": "0x00BdE4C02a920aC7BbfaEa32b72Bb62738a6Cd74",
  
  // The smart contract or destination wallet address
  "to": "0x11111112542d85b3ef69ae05771c2dccff4faa26",
  
  // The data that should be signed
  // It might be null in cases like transferring native token
  "data": "0x7c025200000000000000000000000000baf9a5d4b0052359326a6cda.....",
  
  // The nullable amount field that should be passed to wallet
  "value": "0x0",
  
  // The gas limit field that should be passed to wallet
  "gasLimit": "0x714b3",
  
  // The gas price field that should be passed to wallet
  "gasPrice": null,
  
  // The nonce field that should be passed to wallet
  "nonce": null,
  
  // Indicates that this object is a EVM transaction
  "type": "EVM"
}

Metamask Example

Check SDK Metamask example for sample code of passing this transaction to EVM wallet:

Transfer Transactions

Here is a sample of a transfer object:

"transaction": {
  // Indicates that this object is a simple transfer transaction
  "type": "TRANSFER"
  
  // The method of action, e.g. transfer or deposit
  "method": "transfer",
  
  // User's wallet address  
  "fromWalletAddress": "ltc1qnesqrrsrgn7r25uducukr7dtp297ytp30fjg5r",
  
  // The destination wallet address, example is a Thorchain inbound address
  "recipientAddress": "ltc1qqefsjm654cdw94ejj8g4s49w7z8te75vfjyld3",
  
  // The optional memo message that should be attached, this case Thorchain memo
  "memo": "=:BNB.BNB:bnb1ukfhdgy9c0ws42eqt782039ept9ht6fag88t6u:726187",
  
  // The blockchain-readable amount of asset, example is 0.02 LTC
  "amount": "2000000",
  
  // The decimals of the asset
  "decimals": 8,
  
  "asset": {
    // The blockchain of asset
    "blockchain": "LTC",
    
    // The symbol of asset
    
    "symbol": "LTC",
    // The contract address if asset

    "address": null,
    
    // The ticker of asset, example: BUSD-BD1 in BNB
    "ticker": "LTC"
  }
}

And here is an example of executing transfer transaction using xDefi wallet on LTC:

async function executeTransferTransaction(tx) {
  const provider = window.xfi?.litecoin
  const {
    method, 
    memo, 
    recipientAddress, 
    decimals, 
    amount, 
    fromWalletAddress: from, 
    asset
  } = transfer
  let params = {
    asset: {
      chain: blockchain, 
      symbol: ticker, 
      ticker: ticker
    },
    from: from,    
    amount: {
      amount: amount, 
      decimals: decimals
    },
    memo: memo
  }
  if (recipientAddress)
    params.recipient = recipientAddress
    provider.request({
      method: method, 
      params: [params]
    },
    (error: any, result: any) => {
      console.log('Xdefi transfer result', error, result)
      if (error)
        reject(error)
      else
        resolve(result)
    }
  )
}

COSMOS Transaction

Here is a sample COSMOS transaction consisting of an IBC from Cosmos to Osmosis blockchain:

"transaction": {
  // Indicates that this object is a Cosmos transaction
  "type": "COSMOS"
  
  // Address of the source wallet
  "fromWalletAddress": "cosmos17eytgfra0u3hrancs2yzdaqtt7gr4mw0h5rcd4",

  // Blockchain of the source wallet
  "blockChain": "COSMOS",
	
  // The data that should be passed to wallet [ex: Keplr, Terra Wallet]
  "data": {
   
    // The chainId that is directly passed to wallet 
    "chainId":"cosmoshub-4",
		
    // The accountNumber that is directly passed to wallet
    "accountNumber": 397753,
		
    // The sequence number that is directly passed to wallet
    "sequence": "10",
		
    // The list of messages that wallet is going to sign
    // check this page for different types of messages.
    // Unfortunately you should do minimal modifications depending on your cosmos client sdk
    // See cosmos messages section in this doc for more details
    "msgs": [{
      "type": "cosmos-sdk/MsgTransfer",
      "value": {
        "source_port": "transfer",
        "source_channel": "channel-141",				
        "token":{
      	  "denom": "uatom",
	  "amount": "1000000"
        },
        "sender": "cosmos17eytgfra0u3hrancs2yzdaqtt7gr4mw0h5rcd4",				
        "receiver": "osmo1dnx5yaq8hcx7les42m5mqaxg59udd6j27424sf",
        "timeout_height": {
          "revision_number": "4",
      	  "revision_height": "1762978"
        }
      },
      "__type": "CosmosIBCTransferMessage"
    }],
		
    // The memo that is directly passed to the wallet
    "memo":"",
		
    // The source that is directly passed to wallet
    "source": null,
		
    // The list of fees of transaction that is directly passed to wallet
    "fee": {
      // The gas price of fee item
      "gas": "1200000",
    
      // The amount of fee item including symbol and amount that is directly passed to wallet
      "amount": [{
        "denom": "uatom",
        "amount": "15000"
      }]
    },
		
    // The sign type can be AMINO or DIRECT, check your cosmos SDK on how to handle each type
    // The SDK has two different method calls based on the value
    "signType": "AMINO",
		
    // The rpcUrl that is directly passed to the wallet
    "rpcUrl": null
  },
	
  // The raw transfer object is not null when the cosmos message is equivalent to 
  // a simple transfer. It's useless in the case of Keplr, but in some cases like 
  // BNB tx on xDefi as the wallet does not support cosmos messages, you can 
  // extract transfer data from this field and manually call the wallet's SDK
  "rawTransfer": null,
}

RawTransfer in Cosmos

The raw transfer object is not null when the cosmos message is equivalent to a simple transfer. It's useless in the case of Keplr, but in some cases like BNB tx on XDefi, as the wallet does not support cosmos messages, you should extract transfer data from this field and manually call the wallet's SDK.

Here is a sample of sending 1.0 RUNE in the BNB network:

"rawTransfer": {
  "method": "transfer",
  "asset": {
    "blockchain": "BNB",
    "symbol": "RUNE",
    "address": "b1a",
    "ticker": "RUNE-B1A"
  },
  "amount": "100000000",
  "decimals": 8,
  "recipient": "bnb1s3f8vxaqum3pft6cefyn99px8wq6uk3jdtyarn",
  "memo": "SWITCH:thor1kyrjpjmzs3kcldzacddmggsqyqeg67r6cc3m3f"
}

Keplr & Terra Station Examples

Check SDK Keplr and Terra Station examples for sample code of passing Cosmos transaction to the wallet:

Last updated