meterify.eth
This module allows you to interact with a Meter blockchain and any deployed smart contracts on it.
Although the meterify.eth
module inherits from web.eth
, there are some feature differences between the two. The following is a list of extended features in meterify.eth
Extended Properties
currentProvider
givenProvider
Extended Methods
getBlockRef
getBlockUncleCount
getChainTag
getEnergy
Note on checksum addresses
All addresses returned by functions of this package are returned as checksum addresses. This means some letters are uppercase and some are lowercase. Based on that it will calculate a checksum for the address and prove its correctness. Incorrect checksum addresses will throw an error when passed into functions. If you want to circumvent the checksum check you can make an address all lower- or uppercase.
Checksum Example:
Contract
For meterify.eth.Contract
see the Contract
reference documentation.
accounts
For meterify.eth.accounts
see the accounts
reference documentation.
options
For meterify.eth.options
see the options
reference documentation.
getProtocolVersion
Returns the protocol version of the node.
Example:
Returns:
Type | Description |
| The protocol version. |
isSyncing
Checks if the node is currently syncing and returns either a syncing object, or false
.
Returns:
Type | Description |
Promise <objectboolean> |
Property | Type | Description |
|
| The block number where the sync started. |
|
| The block number where at which block the node currently synced to already. |
|
| The estimated block number to sync to. |
|
| The estimated states to download |
|
| The already downloaded states |
Example:
getCoinbase
Returns the Coinbase address to which mining rewards will go.
Returns:
Type | Description |
| The Coinbase address set in the node for mining rewards. |
Example:
isMining
Checks whether the node is mining or not.
Returns:
Type | Description |
| Returns |
Example:
getHashrate
Returns the number of hashes per second that the node is mining with.
Returns:
Type | Description |
| The number of hashes per second. |
Example:
getGasPrice
Returns the current gas price oracle. The gas price is determined by the last few blocks median gas price. GasPrice is the wei per unit of gas.
Returns:
Type | Description |
| Number string of the current gas price in |
See the A note on dealing with big numbers in JavaScript.
Example:
getAccounts
Will return a list of the unlocked accounts in the Web3 wallet or it will return the accounts from the currently connected node.
This means you can add accounts with meterify.eth.accounts.create()
and you will get them returned here.
Returns:
Type | Description |
| An array of addresses controlled by node. |
Example:
getBlockNumber
Returns the current block number.
Returns:
Type | Description |
| The number of the most recent block. |
Example:
getBalance
Get the Meter MTRG balance of an address at a given block.
Property | Type | Description |
address |
| The address to get the balance of. |
defaultBlock |
| (optional) If you pass this parameter it will not use the default block set with |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| The current Meter balance for the given address in |
See the `A note on dealing with big numbers in JavaScript'.
Example:
getEnergy
Get the Meter MTR (energy) balance of an address at a given block.
Property | Type | Description |
address |
| The address to get the balance of. |
defaultBlock |
| (optional) If you pass this parameter it will not use the default block set with |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| The current Meter MTR balance for the given address in |
See the A note on dealing with big numbers in JavaScript.
Example:
getStorageAt
Get the storage at a specific position of an address.
Parameters:
Property | Type | Description |
address |
| The address to get the storage from. |
position |
| The index position of the storage. |
defaultBlock |
| (optional) If you pass this parameter it will not use the default block set with |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| The value in storage at the given position. |
Example:
getCode
Get the code at a specific address.
Parameters:
Property | Type | Description |
address |
| The address to get the code from. |
defaultBlock |
| (optional) If you pass this parameter it will not use the default block set with |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| The data at given address |
Example:
getBlock
Returns a block matching the block number or block hash.
Parameters:
Property | Type | Description |
blockHashOrBlockNumber |
| The block number or block hash. Or the string |
returnTransactionObjects |
| (optional, default |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| The block object. |
The block object:
Property | Type | Description |
|
| The block number. |
|
| Hash of the block. |
|
| Hash of the parent block. |
|
| Hash of the generated proof-of-work. |
|
| SHA3 of the uncles data in the block. |
|
| The bloom filter for the logs of the block. |
|
| The root of the transaction trie of the block |
|
| The root of the final state trie of the block. |
|
| Transaction receipts are used to store the state after a transaction has been executed and are kept in an index-keyed trie. The hash of its root is placed in the block header as the receipts root. |
|
| The address of the beneficiary to whom the mining rewards were given. |
|
| Integer of the difficulty for this block. |
|
| Integer of the total difficulty of the chain until this block. |
|
| The "extra data" field of this block. |
|
| Integer the size of this block in bytes. |
|
| The maximum gas allowed in this block. |
|
| The total used gas by all transactions in this block. |
|
| The unix timestamp for when the block was collated (returns a string if a overflow got detected). |
|
| Array of transaction objects, or 32 Bytes transaction hashes depending on the |
|
| Array of uncle hashes. |
Example:
getBlockTransactionCount
Returns the number of transaction in a given block.
Parameters:
Property | Type | Description |
blockHashOrBlockNumber |
| The block number or hash. Or the string |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| The number of transactions in the given block. |
Example:
getUncle
Returns a blocks uncle by a given uncle index position.
Parameters:
Property | Type | Description |
blockHashOrBlockNumber |
| The block number or hash. Or the string |
uncleIndex |
| The index position of the uncle. |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| The returned uncle. For a return value see |
Note: An uncle doesn't contain individual transactions.
Example:
getTransaction
Returns a transaction matching the given transaction hash.
Parameters:
Property | Type | Description |
transactionHash |
| The transaction hash. |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| A transaction object its hash |
The object:
Property | Type | Description |
|
| Hash of the transaction. |
|
| The number of transactions made by the sender prior to this one. |
|
| Hash of the block where this transaction was in. |
|
| Block number where this transaction was in. |
|
| Integer of the transactions index position in the block. |
|
| Address of the sender. |
|
| Address of the receiver. |
|
| Value transferred in |
|
| The wei per unit of gas provided by the sender in |
|
| Gas provided by the sender. |
|
| The data sent along with the transaction. |
Example:
getPendingTransactions
Returns a list of pending transactions.
Parameters:
Property | Type | Description |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| Array of pending transactions: |
The object:
Property | Type | Description |
|
| Hash of the transaction. |
|
| The number of transactions made by the sender prior to this one. |
|
| Hash of the block where this transaction was in. |
|
| Block number where this transaction was in. |
|
| Integer of the transactions index position in the block. |
|
| Address of the sender. |
|
| Address of the receiver. |
|
| Value transferred in |
|
| The wei per unit of gas provided by the sender in |
|
| Gas provided by the sender. |
|
| The data sent along with the transaction. |
Example:
getTransactionFromBlock
Returns a transaction based on a block hash or number and the transactions index position.
Parameters:
Property | Type | Description |
hashStringOrNumber |
| A block number or hash. Or the string |
indexNumber |
| The transactions index position. |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| A transaction object, see |
Example:
getTransactionReceipt
Returns the receipt of a transaction by transaction hash.
Note: The receipt is not available for pending transactions and returns null
.
Parameters:
Property | Type | Description |
hash |
| The transaction hash. |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| A transaction receipt object, or |
The object:
Property | Type | Description |
|
|
|
|
| Hash of the block where this transaction was in. |
|
| Block number where this transaction was in. |
|
| Hash of the transaction. |
|
| Integer of the transactions index position in the block. |
|
| Address of the sender. |
|
| Address of the receiver. |
|
| The contract address created, if the transaction was a contract creation, otherwise |
|
| The total amount of gas used when this transaction was executed in the block. |
|
| The amount of gas used by this specific transaction alone. |
|
| Array of log objects, which this transaction generated. |
Example:
getTransactionCount
Get the numbers of transactions sent from this address.
Parameters:
Property | Type | Description |
address |
| The address to get the numbers of transactions from. |
defaultBlock |
| (optional) If you pass this parameter it will not use the default block set with |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| The number of transactions sent from the given address. |
Example:
sendTransaction
Sends a transaction to the network.
Parameters:
Property | Type | Description |
transactionObject |
| The transaction object to send. |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
The transactionObject
Property | Type | Description |
|
| The address for the sending account. Uses the |
|
| (optional) The destination address of the message, left undefined for a contract-creation transaction. |
|
| (optional) The value transferred for the transaction in |
|
| (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded). |
|
| (optional) The price of gas for this transaction in |
|
| (optional) Either a |
|
| (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce. |
Note: The from
property can also be an address or index from the meterify.eth.accounts.wallet
. It will then sign locally using the private key of that account, and send the transaction via meterify.eth.sendSignedTransaction()
.
Returns:
The callback will return the 32 bytes transaction hash.
Name | Description |
| A promise combined event emitter. Will be resolved when the transaction |
Event | Returns | Description |
|
| Is fired right after the transaction is sent and a transaction hash is available. |
|
| Is fired when the transaction receipt is available. |
|
| Is fired for every confirmation up to the 12th confirmation. Receives the confirmation number as the first and the receipt as the second argument. Fired from confirmation 0 on, which is the block where it's mined. |
|
| Is fired if an error occurs during sending. If a out of gas error, the second parameter is the receipt. |
Example:
sendSignedTransaction
Sends an already signed transaction, generated for example using meterify.eth.accounts.signTransaction
.
Parameters:
Property | Type | Description |
signedTransactionData |
| Signed transaction data in HEX format |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Name | Returns | Description |
| Will be resolved when the transaction |
Please see the return values for meterify.eth.sendTransaction
for details.
Example:
sign
Signs data using a specific account. This account needs to be unlocked.
Parameters:
Property | Type | Description |
dataToSign |
| Data to sign. If String it will be converted using |
address |
| Address to sign data with. Or an address or index of a local wallet in |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Note: The 2. address
parameter can also be an address or index from the meterify.eth.accounts.wallet
. It will then sign locally using the private key of this account.
Returns:
Type | Description |
| The signature. |
Example:
signTransaction
Signs a transaction with the private key of the given address. If the given address is a local unlocked account, the transaction will be signed locally.
Parameters:
Property | Type | Description |
transactionObject |
| The transaction data to sign |
address |
| The address of the account. |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| The RLP encoded transaction. The |
Example:
call
Executes a message call transaction, which is directly executed in the VM of the node, but never mined into the blockchain.
Parameters:
Property | Type | Description |
callObject |
| A transaction object see |
defaultBlock |
| (optional) If you pass this parameter it will not use the default block set with |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| The returned data of the call, e.g. a smart contract functions return value. |
Example:
estimateGas
Executes a message call or transaction and returns the amount of the gas used.
Parameters:
Property | Type | Description |
callObject |
| A transaction object see |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| The used gas for the simulated call/transaction. |
Example:
getPastLogs
Gets past logs, matching the given options.
Parameters:
Property | Type | Description |
options |
| The filter options as follows: |
callback |
| (optional) Optional callback, |
The options
object:
Property | Type | Description |
|
| The number of the earliest block ( |
|
| The number of the latest block ( |
|
| An address or a list of addresses to only get logs from particular account(s). |
|
| An array of values which must each appear in the log entries. The order is important, if you want to leave topics out use |
Returns:
Type | Description |
| Array of log objects. |
The structure of the returned event Object
in the Array
looks as follows:
Name | Type | Description |
|
| From which this event originated from. |
|
| The data containing non-indexed log parameter. |
|
| An array with max 4 32 Byte topics, topic 1-3 contains indexed parameters of the log. |
|
| Integer of the event index position in the block. |
|
| Integer of the transaction's index position, the event was created in. |
|
| Hash of the transaction this event was created in. |
|
| Hash of the block where this event was created in. |
|
| The block number where this log was created in. |
Example:
getWork
Gets work for miners to mine on. Returns the hash of the current block, the seedHash, and the boundary condition to be met ("target").
Parameters:
Property | Type | Description |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| The mining work with the following structure: |
Type | Description |
| current block header pow-hash |
| the seed hash used for the DAG. |
| the boundary condition ("target"), 2^256 / difficulty. |
Example:
submitWork
Used for submitting a proof-of-work solution.
Parameters:
Property | Type | Description |
nonce |
| The nonce found (64 bits) |
powHash |
| The header's pow-hash (256 bits) |
digest |
| The mix digest (256 bits) |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| Returns |
Example:
requestAccounts
This method will request/enable the accounts from the current environment it is running (Metamask, Status or Mist). It doesn't work if you're connected to a node with a default Web3.js provider (WebsocketProvider, HttpProvidder and IpcProvider). This method will only work if you're using the injected provider from an application like Status, Mist or Metamask.
For further information about the behavior of this method please read the EIP of it: EIP-1102
Parameters:
Property | Type | Description |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| Returns an array of enabled accounts. |
Example:
getChainId
Returns the chain ID of the current connected node as described in EIP-695
.
Returns:
Type | Description |
| Returns chain ID. |
Example:
getNodeInfo
Returns:
Type | Description |
| The current client version. |
Example:
getProof
Returns the account and storage-values of the specified account including the Merkle-proof as described in EIP-1186
.
Parameters:
Property | Type | Description |
address |
| The Address of the account or contract. |
storageKey |
| Array of storage-keys which should be proofed and included. See |
blockNumber |
| Integer block number, or the string "latest" or "earliest". |
callback |
| (optional) Optional callback, returns an error object as first parameter and the result as second. |
Returns:
Type | Description |
| A account object. |
The account object:
Property | Description |
| The balance of the account. See |
| Hash of the code of the account. For a simple Account without code it will return "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" |
| Nonce of the account. |
| SHA3 of the StorageRoot. All storage will deliver a MerkleProof starting with this rootHash. |
| Array of rlp-serialized MerkleTree-Nodes, starting with the stateRoot-Node, following the path of the SHA3 (address) as key. |
| Array of storage-entries as requested. |
| The requested storage key. |
| The storage value. |
Example:
Last updated