npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rue-tools

v1.0.0

Published

A set of helper functions for ethereum dapps.

Downloads

5

Readme

Ethereum tools

A set of helper functions for ethereum dapps.

See here for a demo of the template helpers.

Installation

You can either add it as a Meteor package using:

$ Meteor add ethereum:tools

or add link to the ethtools.js in your HTML.

Usage

This package provides formating and converting functionality.

When using the EthTools.ticker it will call the cryptocompare.com public API every 30s to retrive price information for ether. When used as a Meteor package, the following units are possible for some methods:

- `btc`
- `usd`
- `eur`
- `cad`
- `gbp`
- `jpy`
- And all ether units ('ether', 'finney', 'wei', etc)

Note As non-meteor package you can only use the ether units.


EthTools.ticker

EthTools.ticker.start();
EthTools.ticker.findOne(unit)

Note This is only available when used as a Meteor package.

To start polling for ticker prices run EthTools.ticker.start()

It gives you the latest price for ether based on the kraken.com public API. EthTools.ticker is a reactive collection, so when used in a reactive function it will re-run this function when the price is updated.

The ticker will be updated every 30 seconds.

Methods

Its a normal Meteor collection

  • start(options) - starts the polling for the ticker, the options object can be an object with {extraParams: 'mydata'} to be added to the ticker polling call
  • findOne(unit) - returns an object with the price of the unit
  • find().fetch() - returns all available price ticker units

Returns

  • Object
{
    _id: 'btc',
    price: '0.02000'
}

Example

var usd = EthTools.ticker.findOne('usd')

if(usd)
    console.log(usd.price) // "2.0000"

EthTools.setLocale

EthTools.setLocale(locale)

Set the locale to display numbers differently in other countries. This functions lets EthTools.formatBalance() and EthTools.formatNumber() reactivly re-run, to show the new format.

Parameters

  • locale (String) - the locale to set

Returns

String - the set locale e.g. en

Example

EthTools.setLocale('de');
EthTools.formatNumber(2000, '0,0.00');
// 2 000,00

EthTools.setUnit

EthTools.setUnit(unit)

Note This is only available when used as a Meteor package.

Reactivly sets a unit used as default unit, when no unit is passed to other EthTools methods. And also persists it in localstorage so its the same when you reload you app.

Default is unit ether.

Parameters

  • unit (String) - the unit to set, see Usage for more

Returns

Boolean - TRUE if the unit is an allowed unit and could be set

Example

EthTools.setUnit('btc');

Tracker.autorun(function(){
    var amount = EthTools.formatBalance('23000000000000000000', '0,0.0[00] unit');
    // amount = "0.287 btc"
});

EthTools.getUnit

EthTools.getUnit()

Note This is only available when used as a Meteor package.

Reactivly gets the current set default unit, used byt other EthTools methods when no unit was passed. And also persists it in localstorage so its the same when you reload you app.

Default is unit ether.

Parameters

none

Returns

String - the current default unit.

Example

EthTools.setUnit('btc');

Tracker.autorun(function(){
    var unit = EthTools.getUnit();
    // unit === 'btc'
});

EthTools.formatNumber

EthTools.formatNumber(number, format)

Formats any number using numeral.js, e.g. "0,0.00[0000]".

Parameters

  • number (String|Number) - the number to format
  • format (String) - the format see numeral.js for examples, e.g. "0,0.00[0000]"

Returns

String - the formated number.

Example

var finney = EthTools.formatNumber(2000, '0,0.00');
// finney = '2,000.00'

Format number template helper

Usage

{{dapp_formatNumber "1000000133" "0,0.00[0000]"}}

EthTools.formatBalance

EthTools.formatBalance(wei, format, unit)

Formats a number of wei into any other ethereum unit and other currencies (see Usage).

Default is unit ether.

The format property follows the numeral.js formatting, e.g. "0,0.00[0000]". Additionally you can add "unit" or "UNIT" (for uppercase) to display the unit after or before the number the number.

Additionally this function uses the reactive EthTools.getUnit() variable, when no unit was given. You can then reactivly change the unit using EthTools.setUnit('finney')

Parameters

  • wei (String|Number) - the amount of wei to convert and format
  • format (String) - the format see numeral.js for examples, e.g. "0,0.00[0000]".
  • unit (String) - (optional) the unit to convert the given wei amount to, if not given it will use EthTools.getUnit()

Returns

String - the formated balance.

Example

var amount = EthTools.formatBalance(112345676543212345, '0,0.0[00] unit', 'finney');
// amount = "112.346 finney"

Format balances template helper

format balances

Usage

{{dapp_formatBalance "1000000133" "0,0.00[0000]" "ether"}}

If you leave the last value it will use EthTools.getUnit(), as reactive localstorage variable.

{{dapp_formatBalance "1000000133" "0,0.00"}}

Use then EthTools.setUnit(finney') to change the unit and displayed balances.


EthTools.toWei

EthTools.toWei(number, unit)

Formats an amount of any supported unit (see Usage) into wei.

Default is unit ether.

Additionally this function uses the reactive EthTools.getUnit() variable, when no unit was given. You can then reactivly change the unit using EthTools.setUnit('finney')

Parameters

  • number (String|Number) - the number of a unit, see Usage for more
  • unit (String) - the unit of the given number

Returns

String - the number in wei.

Example

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