zoukankan      html  css  js  c++  java
  • 以太坊中计量单位及相互转换

    以太币单位转换

    首先我们来看一下以太币单位之间的转换,以太币的最小单位为wei,1个eth相当于10的18次方wei。通常,大家也使用Gwei作为展示单位。比较常用的就是eth,Gwei和wei。

    以太币单位转换

    // wei转换为ether
    > web3.fromWei('22000000000000', 'ether');
    "0.000022"
    
    // wei转换为kwei
    > web3.fromWei('1000','kwei')
    "1"
    
    // wei转换为gwei
    > web3.fromWei('1000000000','gwei')
    "1"
    
    // ether转换为wei
    > web3.toWei('1','ether')
    "1000000000000000000"

    上面表格中列出了以太币之间的单位进制,同样可以使用web3进行相应的转换,基本函数为web3.fromWei和web3.toWei(number, unit)。

    具体实例如下:

  • 相关阅读:
    各职业岗位说明
    感慨集中所
    批量插入测试数据
    写作技巧
    Cordova学习
    CocoStudio
    maven使用感受
    org.json
    ApplicationContext
    2017
  • 原文地址:https://www.cnblogs.com/peteremperor/p/15650363.html
Copyright © 2011-2022 走看看