How to use the web3-utils.fromWei function in web3-utils

To help you get started, we’ve selected a few web3-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NovakDistributed / macroverse / test / TestMacroverseUniversalRegistry.js View on Github external
let expected_planet_cost = parseFloat(Web3Utils.toWei((100 / Math.pow(2, i + 1)).toFixed(18), "ether").toString())
      assert.approximately(parseFloat(planet_land_cost.toString()),
        expected_planet_cost,
        expected_planet_cost * 0.001,
        "planet land cost at level " + i + " is incorrect")
      
      let moon_land_keypath = moon_keypath
      for(let j = 0; j < i; j++) {
        moon_land_keypath = moon_land_keypath + '.0'
      }

      let moon_land_cost = (await instance.getMinDepositToCreate(mv.keypathToToken(moon_land_keypath)))
      console.log('Moon land level ' + i + ' cost: ' +
        Web3Utils.fromWei(moon_land_cost.toString(), 'ether') + ' MRV')
      let expected_moon_cost = 25 / Math.pow(2, i + 1)
      assert.approximately(parseFloat(Web3Utils.fromWei(moon_land_cost.toString(), "ether")),
        expected_moon_cost,
        expected_moon_cost * 0.001,
        "moon land cost at level " + i + " is incorrect")
    }

    
  })
github poanetwork / tokenbridge-contracts / deploy / src / amb_erc677_to_erc677 / initialize.js View on Github external
owner
  },
  upgradeableAdmin,
  sendRawTx
}) {
  let nonce = await web3.eth.getTransactionCount(DEPLOYMENT_ACCOUNT_ADDRESS)

  const contract = new web3.eth.Contract(abi, address)
  console.log(`
    AMB contract: ${bridgeContract}, 
    Mediator contract: ${mediatorContract}, 
    Token contract: ${erc677token},
    DAILY_LIMIT : ${dailyLimit} which is ${Web3Utils.fromWei(dailyLimit)} in eth,
    MAX_AMOUNT_PER_TX: ${maxPerTx} which is ${Web3Utils.fromWei(maxPerTx)} in eth,
    MIN_AMOUNT_PER_TX: ${minPerTx} which is ${Web3Utils.fromWei(minPerTx)} in eth,
    EXECUTION_DAILY_LIMIT : ${executionDailyLimit} which is ${Web3Utils.fromWei(executionDailyLimit)} in eth,
    EXECUTION_MAX_AMOUNT_PER_TX: ${executionMaxPerTx} which is ${Web3Utils.fromWei(executionMaxPerTx)} in eth,
    FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift},
    MEDIATOR_REQUEST_GAS_LIMIT : ${requestGasLimit}, 
    OWNER: ${owner}
  `)

  const initializeData = await contract.methods
    .initialize(
      bridgeContract,
      mediatorContract,
      erc677token,
      [dailyLimit, maxPerTx, minPerTx],
      [executionDailyLimit, executionMaxPerTx],
      requestGasLimit,
      foreignToHomeDecimalShift,
      owner
github poanetwork / tokenbridge-contracts / deploy / src / erc_to_erc / foreign.js View on Github external
async function initializeBridge({ validatorsBridge, bridge, nonce }) {
  console.log(`Foreign Validators: ${validatorsBridge.options.address},
  ERC20_TOKEN_ADDRESS: ${ERC20_TOKEN_ADDRESS},
  FOREIGN_MAX_AMOUNT_PER_TX: ${FOREIGN_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(
    FOREIGN_MAX_AMOUNT_PER_TX
  )} in eth,
  FOREIGN_GAS_PRICE: ${FOREIGN_GAS_PRICE}, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS : ${FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS},
    HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth,
  HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth,
  FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER},
  FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}
  `)

  const initializeFBridgeData = await bridge.methods
    .initialize(
      validatorsBridge.options.address,
      ERC20_TOKEN_ADDRESS,
      FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS,
      FOREIGN_GAS_PRICE,
      [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX],
      [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX],
      FOREIGN_BRIDGE_OWNER,
      foreignToHomeDecimalShift
    )
    .encodeABI()
github poanetwork / tokenbridge-contracts / deploy / src / erc_to_native / home.js View on Github external
[HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX],
        HOME_GAS_PRICE,
        HOME_REQUIRED_BLOCK_CONFIRMATIONS,
        BLOCK_REWARD_ADDRESS,
        [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX],
        HOME_BRIDGE_OWNER,
        feeManager.options.address,
        [homeFeeInWei, foreignFeeInWei],
        foreignToHomeDecimalShift
      )
      .encodeABI()
  } else {
    console.log('\ninitializing Home Bridge with following parameters:\n')
    console.log(`Home Validators: ${validatorsBridge.options.address},
  HOME_DAILY_LIMIT : ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth,
  HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth,
  HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth,
  HOME_GAS_PRICE: ${HOME_GAS_PRICE}, HOME_REQUIRED_BLOCK_CONFIRMATIONS : ${HOME_REQUIRED_BLOCK_CONFIRMATIONS},
  BLOCK_REWARD_ADDRESS: ${BLOCK_REWARD_ADDRESS},
  FOREIGN_DAILY_LIMIT: ${FOREIGN_DAILY_LIMIT} which is ${Web3Utils.fromWei(FOREIGN_DAILY_LIMIT)} in eth,
  FOREIGN_MAX_AMOUNT_PER_TX: ${FOREIGN_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(
      FOREIGN_MAX_AMOUNT_PER_TX
    )} in eth,
  HOME_BRIDGE_OWNER: ${HOME_BRIDGE_OWNER},
  FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}
  `)
    initializeHomeBridgeData = await bridge.methods
      .initialize(
        validatorsBridge.options.address,
        [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX],
        HOME_GAS_PRICE,
        HOME_REQUIRED_BLOCK_CONFIRMATIONS,
github poanetwork / tokenbridge-contracts / deploy / src / erc_to_native / home.js View on Github external
[FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX],
        HOME_BRIDGE_OWNER,
        feeManager.options.address,
        [homeFeeInWei, foreignFeeInWei],
        foreignToHomeDecimalShift
      )
      .encodeABI()
  } else {
    console.log('\ninitializing Home Bridge with following parameters:\n')
    console.log(`Home Validators: ${validatorsBridge.options.address},
  HOME_DAILY_LIMIT : ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth,
  HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth,
  HOME_MIN_AMOUNT_PER_TX: ${HOME_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MIN_AMOUNT_PER_TX)} in eth,
  HOME_GAS_PRICE: ${HOME_GAS_PRICE}, HOME_REQUIRED_BLOCK_CONFIRMATIONS : ${HOME_REQUIRED_BLOCK_CONFIRMATIONS},
  BLOCK_REWARD_ADDRESS: ${BLOCK_REWARD_ADDRESS},
  FOREIGN_DAILY_LIMIT: ${FOREIGN_DAILY_LIMIT} which is ${Web3Utils.fromWei(FOREIGN_DAILY_LIMIT)} in eth,
  FOREIGN_MAX_AMOUNT_PER_TX: ${FOREIGN_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(
      FOREIGN_MAX_AMOUNT_PER_TX
    )} in eth,
  HOME_BRIDGE_OWNER: ${HOME_BRIDGE_OWNER},
  FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}
  `)
    initializeHomeBridgeData = await bridge.methods
      .initialize(
        validatorsBridge.options.address,
        [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX, HOME_MIN_AMOUNT_PER_TX],
        HOME_GAS_PRICE,
        HOME_REQUIRED_BLOCK_CONFIRMATIONS,
        BLOCK_REWARD_ADDRESS,
        [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX],
        HOME_BRIDGE_OWNER,
        foreignToHomeDecimalShift
github poanetwork / tokenbridge-contracts / deploy / src / native_to_erc / foreign.js View on Github external
console.log('[Foreign] feeManager Implementation: ', feeManager.options.address)
    nonce++

    const homeFeeInWei = Web3Utils.toWei(HOME_TRANSACTIONS_FEE.toString(), 'ether')

    console.log('\ninitializing Foreign Bridge with fee contract:\n')
    console.log(`Foreign Validators: ${validatorsBridge.options.address},
  FOREIGN_DAILY_LIMIT : ${FOREIGN_DAILY_LIMIT} which is ${Web3Utils.fromWei(FOREIGN_DAILY_LIMIT)} in eth,
  FOREIGN_MAX_AMOUNT_PER_TX: ${FOREIGN_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(
      FOREIGN_MAX_AMOUNT_PER_TX
    )} in eth,
  FOREIGN_MIN_AMOUNT_PER_TX: ${FOREIGN_MIN_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(
      FOREIGN_MIN_AMOUNT_PER_TX
    )} in eth,
  FOREIGN_GAS_PRICE: ${FOREIGN_GAS_PRICE}, FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS : ${FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS},
    HOME_DAILY_LIMIT: ${HOME_DAILY_LIMIT} which is ${Web3Utils.fromWei(HOME_DAILY_LIMIT)} in eth,
  HOME_MAX_AMOUNT_PER_TX: ${HOME_MAX_AMOUNT_PER_TX} which is ${Web3Utils.fromWei(HOME_MAX_AMOUNT_PER_TX)} in eth,
  FOREIGN_BRIDGE_OWNER: ${FOREIGN_BRIDGE_OWNER},
  Fee Manager: ${feeManager.options.address},
  Home Fee: ${homeFeeInWei} which is ${HOME_TRANSACTIONS_FEE * 100}%,
  FOREIGN_TO_HOME_DECIMAL_SHIFT: ${foreignToHomeDecimalShift}
  Home bridge Address: ${homeBridgeAddress}`)

    initializeFBridgeData = await bridge.methods
      .rewardableInitialize(
        validatorsBridge.options.address,
        erc677bridgeToken.options.address,
        [FOREIGN_DAILY_LIMIT, FOREIGN_MAX_AMOUNT_PER_TX, FOREIGN_MIN_AMOUNT_PER_TX],
        FOREIGN_GAS_PRICE,
        FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS,
        [HOME_DAILY_LIMIT, HOME_MAX_AMOUNT_PER_TX],
        FOREIGN_BRIDGE_OWNER,
github MyEtherWallet / MyEtherWallet / src / components / SettingsModal / SettingsModal.vue View on Github external
gwei: new BigNumber(
            utils.fromWei(
              new BigNumber(this.gasPrice).div(1).toFixed(0),
              'gwei'
            )
          ).toFixed(),
          eth: new BigNumber(
            utils.fromWei(
              new BigNumber(this.gasPrice).div(1).toFixed(0),
              'ether'
            )
          ).toFixed()
        },
        regular: {
          gwei: new BigNumber(
            utils.fromWei(
              new BigNumber(this.gasPrice).times(1.5).toFixed(0),
              'gwei'
            )
          ).toFixed(),
          eth: new BigNumber(
            utils.fromWei(
              new BigNumber(this.gasPrice).times(1.5).toFixed(0),
              'ether'
            )
          ).toFixed()
        },
        fast: {
          gwei: new BigNumber(
            utils.fromWei(
              new BigNumber(this.gasPrice).times(2).toFixed(0),
              'gwei'