tools/setup/fund_manager.js
async function(senderAddr, senderPassphrase, recipient, amountInWei) {
    // TODO: should we have isAsync with UUID (unlock account will take time) and also tag, publish events?
    const oThis = this
      , web3Provider = web3ProviderFactory.getProvider('value', 'ws')
      , gasPrice = coreConstants.OST_VALUE_GAS_PRICE
      , gas = coreConstants.OST_VALUE_GAS_LIMIT
    ;

    // Validations
    if (!basicHelper.isAddressValid(senderAddr)) {
      let errObj = responseHelper.error({
        internal_error_identifier: 't_s_fm_1',
        api_error_identifier: 'invalid_address',
        error_config: basicHelper.fetchErrorConfig()
      });

      return Promise.resolve(errObj);
    }

    if (!basicHelper.isAddressValid(recipient)) {
      let errObj = responseHelper.error({
        internal_error_identifier: 't_s_fm_2',
        api_error_identifier: 'invalid_address',
        error_config: basicHelper.fetchErrorConfig()
      });

      return Promise.resolve(errObj);
    }

    if (senderAddr.equalsIgnoreCase(recipient)) {
      let errObj = responseHelper.error({
        internal_error_identifier: 't_s_fm_3',
        api_error_identifier: 'sender_and_recipient_same',
        error_config: basicHelper.fetchErrorConfig()
      });

      return Promise.resolve(errObj);
    }

    if (!basicHelper.isNonZeroWeiValid(amountInWei)) {
      let errObj = responseHelper.error({
        internal_error_identifier: 't_s_fm_4',
        api_error_identifier: 'invalid_amount',
        error_config: basicHelper.fetchErrorConfig()
      });

      return Promise.resolve(errObj);
    }

    // Convert amount in BigNumber
    var bigNumAmount = basicHelper.convertToBigNumber(amountInWei);

    // Validate sender balance
    const senderBalanceValidationResponse = await oThis.validateEthBalance(senderAddr, bigNumAmount);
    if (senderBalanceValidationResponse.isFailure()) {
      return Promise.resolve(senderBalanceValidationResponse);
    }

    // Perform transfer async
    const asyncTransfer = async function() {
      return web3Provider.eth.personal.unlockAccount(senderAddr, senderPassphrase)
        .then(function() {
          return web3Provider.eth.sendTransaction(
            {from: senderAddr, to: recipient, value: bigNumAmount.toString(10), gasPrice: gasPrice, gas: gas});
        })
        .then(function(transactionHash) {
          return responseHelper.successWithData({transactionHash: transactionHash});
        })
        .catch(function(reason) {
          logger.error('reason', reason);

          return responseHelper.error({
            internal_error_identifier: 't_s_fm_5',
            api_error_identifier: 'something_went_wrong',
            error_config: basicHelper.fetchErrorConfig()
          });
        });
    };

    return asyncTransfer();
  }
async function(senderAddr, senderPassphrase, recipient, amountInWei) {
    // TODO: should we have isAsync with UUID (unlock account will take time) and also tag, publish events?
    const oThis = this
      , web3Provider = web3ProviderFactory.getProvider('value', 'ws')
      , gasPrice = coreConstants.OST_VALUE_GAS_PRICE
      , gas = coreConstants.OST_VALUE_GAS_LIMIT
    ;

    // Validations
    if (!basicHelper.isAddressValid(senderAddr)) {
      let errObj = responseHelper.error({
        internal_error_identifier: 't_s_fm_1',
        api_error_identifier: 'invalid_address',
        error_config: basicHelper.fetchErrorConfig()
      });

      return Promise.resolve(errObj);
    }

    if (!basicHelper.isAddressValid(recipient)) {
      let errObj = responseHelper.error({
        internal_error_identifier: 't_s_fm_2',
        api_error_identifier: 'invalid_address',
        error_config: basicHelper.fetchErrorConfig()
      });

      return Promise.resolve(errObj);
    }

    if (senderAddr.equalsIgnoreCase(recipient)) {
      let errObj = responseHelper.error({
        internal_error_identifier: 't_s_fm_3',
        api_error_identifier: 'sender_and_recipient_same',
        error_config: basicHelper.fetchErrorConfig()
      });

      return Promise.resolve(errObj);
    }

    if (!basicHelper.isNonZeroWeiValid(amountInWei)) {
      let errObj = responseHelper.error({
        internal_error_identifier: 't_s_fm_4',
        api_error_identifier: 'invalid_amount',
        error_config: basicHelper.fetchErrorConfig()
      });

      return Promise.resolve(errObj);
    }

    // Convert amount in BigNumber
    var bigNumAmount = basicHelper.convertToBigNumber(amountInWei);

    // Validate sender balance
    const senderBalanceValidationResponse = await oThis.validateEthBalance(senderAddr, bigNumAmount);
    if (senderBalanceValidationResponse.isFailure()) {
      return Promise.resolve(senderBalanceValidationResponse);
    }

    // Perform transfer async
    const asyncTransfer = async function() {
      return web3Provider.eth.personal.unlockAccount(senderAddr, senderPassphrase)
        .then(function() {
          return web3Provider.eth.sendTransaction(
            {from: senderAddr, to: recipient, value: bigNumAmount.toString(10), gasPrice: gasPrice, gas: gas});
        })
        .then(function(transactionHash) {
          return responseHelper.successWithData({transactionHash: transactionHash});
        })
        .catch(function(reason) {
          logger.error('reason', reason);

          return responseHelper.error({
            internal_error_identifier: 't_s_fm_5',
            api_error_identifier: 'something_went_wrong',
            error_config: basicHelper.fetchErrorConfig()
          });
        });
    };

    return asyncTransfer();
  }
async function ( senderAddr , senderPassphrase , recipient , amountInWei ) { // TODO: should we have isAsync with UUID (unlock account will take time) and also tag, publish events? const oThis = this , web3Provider = web3ProviderFactory . getProvider ( 'value' , 'ws' ) , gasPrice = coreConstants . OST_VALUE_GAS_PRICE , gas = coreConstants . OST_VALUE_GAS_LIMIT ; // Validations if ( ! basicHelper . isAddressValid ( senderAddr ) ) { let errObj = responseHelper . error ( { internal_error_identifier : 't_s_fm_1' , api_error_identifier : 'invalid_address' , error_config : basicHelper . fetchErrorConfig ( ) } ) ; return Promise . resolve ( errObj ) ; } if ( ! basicHelper . isAddressValid ( recipient ) ) { let errObj = responseHelper . error ( { internal_error_identifier : 't_s_fm_2' , api_error_identifier : 'invalid_address' , error_config : basicHelper . fetchErrorConfig ( ) } ) ; return Promise . resolve ( errObj ) ; } if ( senderAddr . equalsIgnoreCase ( recipient ) ) { let errObj = responseHelper . error ( { internal_error_identifier : 't_s_fm_3' , api_error_identifier : 'sender_and_recipient_same' , error_config : basicHelper . fetchErrorConfig ( ) } ) ; return Promise . resolve ( errObj ) ; } if ( ! basicHelper . isNonZeroWeiValid ( amountInWei ) ) { let errObj = responseHelper . error ( { internal_error_identifier : 't_s_fm_4' , api_error_identifier : 'invalid_amount' , error_config : basicHelper . fetchErrorConfig ( ) } ) ; return Promise . resolve ( errObj ) ; } // Convert amount in BigNumber var bigNumAmount = basicHelper . convertToBigNumber ( amountInWei ) ; // Validate sender balance const senderBalanceValidationResponse = await oThis . validateEthBalance ( senderAddr , bigNumAmount ) ; if ( senderBalanceValidationResponse . isFailure ( ) ) { return Promise . resolve ( senderBalanceValidationResponse ) ; } // Perform transfer async const asyncTransfer = async function ( ) { return web3Provider . eth . personal . unlockAccount ( senderAddr , senderPassphrase ) . then ( function ( ) { return web3Provider . eth . sendTransaction ( { from : senderAddr , to : recipient , value : bigNumAmount . toString ( 10 ) , gasPrice : gasPrice , gas : gas } ) ; } ) . then ( function ( transactionHash ) { return responseHelper . successWithData ( { transactionHash : transactionHash } ) ; } ) . catch ( function ( reason ) { logger . error ( 'reason' , reason ) ; return responseHelper . error ( { internal_error_identifier : 't_s_fm_5' , api_error_identifier : 'something_went_wrong' , error_config : basicHelper . fetchErrorConfig ( ) } ) ; } ) ; } ; return asyncTransfer ( ) ; }
Transfer ETH on a particular chain from sender to receiver

@param {string} senderAddr - address of user who is sending amount
@param {string} senderPassphrase - sender address passphrase
@param {string} recipient - address of user who is receiving amount
@param {BigNumber} amountInWei - amount which is being transferred

@return {promise<result>}
Transfer ETH on a particular chain from sender to receiver