src/client/index.js
/**
   * Transfer tokens from one address to another.
   * @param {String} fromAddress
   * @param {String} toAddress
   * @param {Number} amount
   * @param {String} asset
   * @param {String} memo optional memo
   * @param {Number} sequence optional sequence
   * @return {Object} response (success or fail)
   */
Transfer tokens from one address to another.
Transfer tokens from one address to another .
async transfer(fromAddress, toAddress, amount, asset, memo="", sequence=null) {
    const accCode = crypto.decodeAddress(fromAddress)
    const toAccCode = crypto.decodeAddress(toAddress)
    amount = parseInt(amount * Math.pow(10, 8))
    checkNumber(amount, "amount")
    const coin = {
      denom: asset,
      amount: amount,
    }
    const msg = {
      inputs: [{
        address: accCode,
        coins: [coin]
      }],
      outputs: [{
        address: toAccCode,
        coins: [coin]
      }],
      msgType: "MsgSend"
    }
    const signMsg = {
      inputs: [{
        address: fromAddress,
        coins: [{
          amount: amount,
          denom: asset
        }]
      }],
      outputs: [{
        address: toAddress,
        coins: [{
          amount: amount,
          denom: asset
        }]
      }]
    }
    const signedTx = await this._prepareTransaction(msg, signMsg, fromAddress, sequence, memo)
    return this._broadcastDelegate(signedTx)
  }
async transfer ( fromAddress , toAddress , amount , asset , memo = "" , sequence = null ) { const accCode = crypto . decodeAddress ( fromAddress ) const toAccCode = crypto . decodeAddress ( toAddress ) amount = parseInt ( amount * Math . pow ( 10 , 8 ) ) checkNumber ( amount , "amount" ) const coin = { denom : asset , amount : amount , } const msg = { inputs : [ { address : accCode , coins : [ coin ] } ] , outputs : [ { address : toAccCode , coins : [ coin ] } ] , msgType : "MsgSend" } const signMsg = { inputs : [ { address : fromAddress , coins : [ { amount : amount , denom : asset } ] } ] , outputs : [ { address : toAddress , coins : [ { amount : amount , denom : asset } ] } ] } const signedTx = await this . _prepareTransaction ( msg , signMsg , fromAddress , sequence , memo ) return this . _broadcastDelegate ( signedTx ) }
Transfer tokens from one address to another.
Transfer tokens from one address to another .