No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
frozeman Merge pull request #4 from ryanio/web3.js-1.0.0-beta.33
Upgrade to web3.js-1.0.0-beta.33
Latest commit 4903a4b Mar 22, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.

Ethereum blocks

Provides you with an EthBlocks collection, which stores the last 50 blocks.

You can query blocks like any other Meteor collection.


$ meteor add ethereum:blocks


Initialize Blocks on the start of your application, as soon as you have a ethereum connection:


Last block

To get the latest block use:


Note this property is reactive, so it will re-run your reactive functions, e.g. when used in template helpers.

In case you want to update the latest block you can change properties as follows:

EthBlocks.latest = { hash: "12345" };

This would only change the hash property of the latest block, but leave all other properties as is.

Current gas price

Additionally all blocks get the current gasprice add:

EthBlocks.latest.gasPrice; // '1136672632018' (wei)

Detecting forks

You can call Blocks.detectFork(callback) to detect chain re-organisation (forks), while your applications is running. This detection, is checking the new incoming blocks parentHash, with the last known block you have.

Note The fork detection can currently be wrong, when you're importing blocks, as they can come in different orders.

EthBlocks.detectFork(function(oldBlock, newBlock) {
  // this callback will be fired with the old block we knew and the new block.

Note you can call EthBlocks.detectFork(cb) mutliple times, to add multiple callbacks.

Clear all stored blocks

If you switch to a chain, which has a lower block number EthBlocks will reset your interally cache of the last 50 blocks. If you want to do that manually call: