EtherscanApi
Kind: global class
- EtherscanApi
- new EtherscanApi([token], [networkName])
- .getAccountBalance(address, [options]) ⇒
Promise.<string>
- .getAccountBalances(addresses, [options]) ⇒
Promise.<object>
- .getTransactions(address, [options]) ⇒
Promise.<Array.<object>>
- .getInternalTransactions(address, [options]) ⇒
Promise.<Array.<object>>
- .getInternalTransactionsByHash(txhash) ⇒
Promise.<Array.<object>>
- .getMinedBlocks(address, [options]) ⇒
Promise.<Array.<object>>
- .getContractAbi(address) ⇒
Promsie.<Array.<object>>
- .getContractExecutionStatus(txhash) ⇒
Promise.<object>
- .getTransactionStatus(txhash) ⇒
Promise.<object>
- .getBlockReward(blockNumber)
- .getEventsLogs(address, options) ⇒
Promise.<object>
- .getRecentBlockNumber() ⇒
Promise.<number>
- .getBlockByNumber(blockNumber) ⇒
Promise.<object>
- .getUncleByBlockNumberAndIndex(blockNumber, [index]) ⇒
Promise.<object>
- .getBlockTransactionCount(blockNumber) ⇒
Promise.<number>
- .getTransactionByHash(txhash) ⇒
Promise.<object>
- .getTransactionByBlockNumberAndIndex(blockNumber, [index]) ⇒
Promise.<object>
- .getTransactionCount(address, [options]) ⇒
Promise.<number>
- .sendRawTransaction(hex) ⇒
Promise.<void>
- .getTransactionReceipt(txhash) ⇒
Promise.<object>
- .call(to, data, [options]) ⇒
Promise.<string>
- .getCode(address, [options]) ⇒
Promise.<string>
- .getStorageAt(address, position, options) ⇒
Promise.<string>
- .getGasPrice([options]) ⇒
Promise.<string>
- .estimateGas(toAddress, options) ⇒
Promise.<void>
- .getTokenByContractAddress(contractAddress) ⇒
Promise.<string>
- .getTokenBalanceByContractAddress(contractAddress, address, [options]) ⇒
Promise.<string>
- .getTotalEtherSupply() ⇒
Promise.<string>
- .getEtherLastPrice() ⇒
Promise.<object>
Param | Type | Default | Description |
---|---|---|---|
[token] | string |
Etherscan API token | |
[networkName] | string |
"MAIN" |
Network name. Available: main, ropsten, kovan and rinkeby |
Returns Ether balance for a single address
Kind: instance method of EtherscanApi
Todo
- Write test for options
Param | Type | Default | Description |
---|---|---|---|
address | string |
Address | |
[options] | object |
||
[options.unit] | string |
"wei" |
Balance unit |
[options.tag] | string |
"latest" |
Returns Ether balance for multiple addresses in a single call. Up to a maximum of 20 accounts in a single batch.
Kind: instance method of EtherscanApi
Todo
- Write test for options
Param | Type | Default | Description |
---|---|---|---|
addresses | Array.<string> |
List of addresses | |
[options] | object |
||
[options.unit] | string |
"wei" |
Balance unit |
[options.tag] | string |
"latest" |
Returns a list of 'Normal' transactions by address. Returns up to a maximum of the last 10000 transactions only.
Kind: instance method of EtherscanApi
Param | Type | Description |
---|---|---|
address | string |
Contract address |
[options] | object |
|
[options.startBlock] | object |
Starting block number to retrieve results |
[options.endBlock] | string | number |
Ending block number to retrieve results |
[options.offset] | number |
Max records to return |
[options.page] | number |
Page number |
[options.sort] | "asc" | "desc" |
Sort type |
Returns a list of 'Internal' Transactions by Address. Returns up to a maximum of the last 10000 transactions only.
Kind: instance method of EtherscanApi
Param | Type | Description |
---|---|---|
address | string |
Contract address |
[options] | object |
|
[options.startBlock] | string | number |
Starting block number to retrieve results |
[options.endBlock] | string | number |
Ending block number to retrieve results |
[options.offset] | string | number |
Max records to return |
[options.page] | string | number |
Page number |
[options.sort] | "asc" | "desc" |
Sort type |
Returns a list of 'Internal' Transactions by Address
Kind: instance method of EtherscanApi
Param | Description |
---|---|
txhash | Contract address |
List of blocks mined by address
Kind: instance method of EtherscanApi
Param | Type | Description |
---|---|---|
address | string |
Miner address |
[options] | object |
|
[options.type] | "blocks" | "uncles" |
Type of block: blocks (full blocks only) or uncles (uncle blocks only) |
[options.offset] | number |
Max records to return |
[options.page] | number |
Page number |
Returns Contract ABI
Kind: instance method of EtherscanApi
Param |
---|
address |
Checks contract execution status (if there was an error during contract execution). "isError": "0" = Pass, "isError": "1" = Error during contract execution
Kind: instance method of EtherscanApi
Param | Type | Description |
---|---|---|
txhash | string |
Contract address |
Checks transaction receipt status (only applicable for post byzantium fork transactions). Status: 0 = Fail, 1 = Pass. Will return null/empty value for pre-byzantium fork
Kind: instance method of EtherscanApi
Param | Type | Description |
---|---|---|
txhash | string |
Transaction address |
Get block and uncle rewards by block number
Kind: instance method of EtherscanApi
Param | Type | Description |
---|---|---|
blockNumber | number |
The number of the block |
Returns events logs. The Event Log API was designed to provide an alternative to the native eth_getLogs. Topic Operator choices are either 'and' or 'or' and are restricted to the above choices only. For performance and security considerations, only the first 1000 results are return.
Kind: instance method of EtherscanApi
Param | Type | Description |
---|---|---|
address | string |
|
options | object |
|
options.fromBlock | number |
Start block number (integer, NOT hex) |
options.toBlock | number | 'latest' |
End block number or "latest" (earliest and pending is NOT supported yet) |
options.topic0 | string |
Topic 0 |
[options.topic01operator] | "and" | "or" |
Operator between topic0 & topic1 |
[options.topic1] | string |
Topic 1 |
[options.topic12operator] | "and" | "or" |
Operator between topic1 & topic2 |
[options.topic2] | string |
Topic 2 |
[options.topic23operator] | "and" | "or" |
Operator between topic2 & topic3 |
[options.topic3] | string |
Topic 3 |
[options.topic02operator] | "and" | "or" |
Operator between topic0 & topic2 |
Returns the number of the most recent block
Kind: instance method of EtherscanApi
Returns information about a block by block number
Kind: instance method of EtherscanApi
Param | Type | Description |
---|---|---|
blockNumber | number |
Block number |
Returns information about a uncle by block number and index
Kind: instance method of EtherscanApi
Param | Type | Default |
---|---|---|
blockNumber | number |
|
[index] | number |
0 |
Returns the number of transactions in a block from a block matching the given block number
Kind: instance method of EtherscanApi
Param | Type |
---|---|
blockNumber | number |
Returns the information about a transaction requested by transaction hash
Kind: instance method of EtherscanApi
Param | Type | Description |
---|---|---|
txhash | string |
Transaction hash |
Returns information about a transaction by block number and transaction index position
Kind: instance method of EtherscanApi
Param | Type | Default |
---|---|---|
blockNumber | number |
|
[index] | number |
0 |
Returns the number of transactions sent from an address
Kind: instance method of EtherscanApi
Param | Type | Default | Description |
---|---|---|---|
address | string |
Transaction address | |
[options] | object |
||
[options.tag] | string |
"latest" |
Creates new message call transaction or a contract creation for signed transactions
Kind: instance method of EtherscanApi
Param | Type | Description |
---|---|---|
hex | string |
Raw hex encoded transaction that you want to send |
Returns the receipt of a transaction by transaction hash
Kind: instance method of EtherscanApi
Param | Type | Description |
---|---|---|
txhash | string |
Transaction hash |
Executes a new message call immediately without creating a transaction on the block chain
Kind: instance method of EtherscanApi
Param | Type | Default | Description |
---|---|---|---|
to | string |
Address to execute from | |
data | string |
Data to transfer | |
[options] | object |
||
[options.tag] | string |
"latest" |
Returns code at a given address
Kind: instance method of EtherscanApi
Param | Type | Default |
---|---|---|
address | string |
|
[options] | object |
|
[options.tag] | string |
"latest" |
Returns the value from a storage position at a given address.
Kind: instance method of EtherscanApi
Param | Type | Default |
---|---|---|
address | string |
|
position | number |
|
options | object |
|
[options.tag] | string |
"latest" |
Returns the current price per gas (in wei by default)
Kind: instance method of EtherscanApi
Param | Type | Default | Description |
---|---|---|---|
[options] | object |
||
[options.unit] | string |
"wei" |
Unit of gas |
Makes a call or transaction, which won't be added to the blockchain and returns the used gas, which can be used for estimating the used gas
Kind: instance method of EtherscanApi
Param | Type | Description |
---|---|---|
toAddress | string |
Address to get code from |
options | object |
|
options.value | string |
Storage position |
options.gasPrice | string |
Gas price in wei |
options.gas | string |
Returns ERC20-Token total supply by contract address
Kind: instance method of EtherscanApi
Param | Type |
---|---|
contractAddress | string |
etherscanApi.getTokenBalanceByContractAddress(contractAddress, address, [options]) ⇒ Promise.<string>
Returns ERC20-Token account balance by token's contract address
Kind: instance method of EtherscanApi
Param | Type | Default |
---|---|---|
contractAddress | string |
|
address | string |
|
[options] | object |
|
[options.tag] | object |
latest |
Returns total supply of Ether
Kind: instance method of EtherscanApi
Returns Ether last price
Kind: instance method of EtherscanApi