Meter Docs
Search…
meterify.module.options
A module provides several options for configuring the transaction confirmation workflow or for defining default values. This document describes the available option properties on a module.
Example:
1
import Web3 from 'web3';
2
3
const meterify = require("meterify").meterify;
4
5
const options = {
6
defaultAccount: '0x0',
7
defaultBlock: 'latest',
8
defaultGas: 1,
9
defaultGasPrice: 0,
10
transactionBlockTimeout: 50,
11
transactionConfirmationBlocks: 24,
12
transactionPollingTimeout: 480,
13
transactionSigner: new CustomTransactionSigner()
14
}
15
16
const web3 = new Web3('http://test.meter.io:8669', null, options);
17
18
const meterify = meterify(web3, "http://test.meter.io:8669");
Copied!

defaultBlock

1
web3.defaultBlock
2
web3.eth.defaultBlock
3
web3.shh.defaultBlock
4
...
Copied!
1
web3.eth.getBalance();
2
web3.eth.getCode();
3
web3.eth.getTransactionCount();
4
web3.eth.getStorageAt();
5
web3.eth.call();
6
new web3.eth.Contract() -> myContract.methods.myMethod().call();`
Copied!
The default block is used for all methods which have a block parameter. You can override it by passing the block parameter if a block is required.
The defaultBlock property can return the following values:
Value
Type
Description
a number
Number
A block number
genesis
String
The genesis block
latest
String
The latest block (current head of the blockchain)
pending
String
The currently mined block (including pending transactions)
Default is latest

defaultAccount

1
web3.defaultAccount
2
web3.eth.defaultAccount
3
web3.shh.defaultAccount
4
...
Copied!
This default address is used as the default "from" property, if no "from" property is specified.
Returns:
Type
Description
String - 20 Bytes
Any Ethereum address. You need to have the private key for that address in your node or keystore. (Default is undefined)

defaultGasPrice

1
web3.defaultGasPrice
2
web3.eth.defaultGasPrice
3
web3.shh.defaultGasPrice
4
...
Copied!
The default gas price which will be used for a request.
Returns:
Type
Description
string or number
The current value of the defaultGasPrice property.

defaultGas

1
web3.defaultGas
2
web3.eth.defaultGas
3
web3.shh.defaultGas
4
...
Copied!
The default gas which will be used for a request.
Returns:
Type
Description
string or number
The current value of the defaultGas property.

transactionBlockTimeout

1
web3.transactionBlockTimeout
2
web3.eth.transactionBlockTimeout
3
web3.shh.transactionBlockTimeout
4
...
Copied!
The transactionBlockTimeout will be used over a socket-based connection. This option does define the amount of new blocks it should wait until the first confirmation happens. This means the PromiEvent rejects with a timeout error when the timeout got exceeded.
Returns:
Type
Description
number
The current value of transactionBlockTimeout

transactionConfirmationBlocks

1
web3.transactionConfirmationBlocks
2
web3.eth.transactionConfirmationBlocks
3
web3.shh.transactionConfirmationBlocks
4
...
Copied!
This defines the number of blocks it requires until a transaction will be handled as confirmed.
Returns:
Type
Description
number
The current value of transactionConfirmationBlocks

transactionPollingTimeout

1
web3.transactionPollingTimeout
2
web3.eth.transactionPollingTimeout
3
web3.shh.transactionPollingTimeout
4
...
Copied!
The transactionPollingTimeout will be used over a HTTP connection. This option does define the amount of polls (each second) it should wait until the first confirmation happens.
Returns:
Type
Description
number
The current value of transactionPollingTimeout

transactionSigner

1
web3.eth.transactionSigner
2
...
Copied!
The TransactionSigner property does provide us the possibility to customize the signing process of the Eth module and the related sub-modules.
The interface of a TransactionSigner:
1
2
interface TransactionSigner {
3
sign(txObject: Transaction): Promise<SignedTransaction>
4
}
5
6
interface SignedTransaction {
7
messageHash: string,
8
v: string,
9
r: string,
10
s: string,
11
rawTransaction: string
12
}
Copied!
Returns:
Type
Description
TransactionSigner
A JavaScript class of type TransactionSigner.

setProvider

1
2
web3.setProvider(myProvider)
3
web3.eth.setProvider(myProvider)
4
web3.shh.setProvider(myProvider)
5
...
Copied!
Will change the provider for its module.
Example:
1
2
import Web3 from 'web3';
3
4
const web3 = new Web3('http://localhost:8545');
5
6
// or
7
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
8
9
// change provider
10
web3.setProvider('ws://localhost:8546');
11
// or
12
web3.setProvider(new Web3.providers.WebsocketProvider('ws://localhost:8546'));
13
14
// Using the IPC provider in node.js
15
const net = require('net');
16
const web3 = new Web3('/Users/myuser/Library/Ethereum/geth.ipc', net); // mac os path
17
18
// or
19
const web3 = new Web3(new Web3.providers.IpcProvider('/Users/myuser/Library/Ethereum/geth.ipc', net)); // mac os path
20
// on windows the path is: '\\\\.\\pipe\\geth.ipc'
21
// on linux the path is: '/users/myuser/.ethereum/geth.ipc'
Copied!
Note: When called on the umbrella package web3 it will also set the provider for all sub modules web3.eth, web3.shh, etc.
Parameters:
Type
Description
Object or String
provider: a valid provider
Net
net: (optional) the node.js Net package. This is only required for the IPC provider.
Returns:
Boolean

providers

1
2
Web3.providers
3
Eth.providers
4
...
Copied!
Example:
1
2
const Web3 = require('web3');
3
// use the given Provider, e.g in Mist, or instantiate a new websocket provider
4
const web3 = new Web3(Web3.givenProvider || 'ws://localhost:8546');
5
// or
6
const web3 = new Web3(Web3.givenProvider || new Web3.providers.WebsocketProvider('ws://localhost:8546'));
7
8
// Using the IPC provider in node.js
9
const net = require('net');
10
11
const web3 = new Web3('/Users/myuser/Library/Ethereum/geth.ipc', net); // mac os path
12
// or
13
const web3 = new Web3(new Web3.providers.IpcProvider('/Users/myuser/Library/Ethereum/geth.ipc', net)); // mac os path
14
// on windows the path is: '\\\\.\\pipe\\geth.ipc'
15
// on linux the path is: '/users/myuser/.ethereum/geth.ipc'
Copied!
Contains the current available providers.
Object with the following providers:
Property
Name
Description
Object
HttpProvider
The HTTP provider is deprecated, as it will not work for subscriptions.
Object
WebsocketProvider
The Websocket provider is the standard for usage in legacy browsers.
Object
IpcProvider
The IPC provider is used node dapps when running a local node. Gives the most secure connection.

givenProvider

1
Web3.givenProvider
2
web3.eth.givenProvider
3
web3.shh.givenProvider
4
...
Copied!
Example:
1
2
web3.setProvider(Web3.givenProvider || 'ws://localhost:8546');
Copied!
When using web3.js in an Ethereum compatible browser, it will set with the current native provider by that browser. Will return the given provider by the (browser) environment, otherwise null.
Returns:
Type
Description
Object
The given provider set or false.

currentProvider

1
2
web3.currentProvider
3
web3.eth.currentProvider
4
web3.shh.currentProvider
5
...
Copied!
Will return the current provider.
Example:
1
2
if (!web3.currentProvider) {
3
web3.setProvider('http://localhost:8545');
4
}
Copied!
Returns:
Type
Description
Object
The current provider set.

BatchRequest

1
2
new web3.BatchRequest()
3
new web3.eth.BatchRequest()
4
new web3.shh.BatchRequest()
5
...
Copied!
Example:
1
2
const contract = new web3.eth.Contract(abi, address);
3
4
const batch = new web3.BatchRequest();
5
batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest'));
6
batch.add(contract.methods.balance(address).call.request({from: '0x0000000000000000000000000000000000000000'}));
7
batch.execute().then(...);
Copied!
Class to create and execute batch requests.
Parameters:
none
Returns:
Type
Description
Object
Contains the following methods:
Method
Description
add(request)
To add a request object to the batch call.
execute()
Will execute the batch request.
Last modified 1yr ago