Improved ethereum:tools and ethereum:elements

Right when kraken.com starts trading I’ve add a new EthTools.formatBalance() method to the ethereum:tools package, which allows you to display an ethereum wei value in any ether unit or supported currency from kraken (BTC, USD, EUR, CAD, GBP and JPY).

Simply use:

// HTML/Blaze
{{dapp_formatBalance "1000000000000000000" "0,0.00[0000] UNIT" "btc"}}

 // JS
 EthTools.formatBalance("1000000000000000000", "0,0.00[0000] UNIT", "btc")
 // "0.012345 BTC"

I’ve also add a special EthTools.toWei() method, which allows you to convert e.g. BTC to to wei:

 var wei = EthTools.toWei(23, 'btc');
 // wei = "80000000000000000000"

There are many more helpful methods (EthTools.formatNumber(), EthTools.setUnit(), EthTools.getUnit, EthTools.ticker, EthTools.setLocale()) in that package take a look its readme for more.

Note that the ethereum:tools package can also used by non-meteor applications, simply link to the ethtools.js, but you won’t have the conversion to the kraken currencies build in 😐

Additionally the ethereum:elements {{> dapp_selectGasPrice}} element now also reacts to EthTools.setUnit(), (if you don’t pass a fixed unit) and can also display gas in BTC, USD, EUR, CAD, GBP and JPY.

I hope you like the tools. If you want to see how to use the elements take look at the demo and its source code.

  • Finibhire Syte

    First time seeing this project since I got on the DApp mailing list. It looks great and also looks like it’s coming along well! Great work!