Skip to content

Latest commit

 

History

History
433 lines (310 loc) · 18.6 KB

API.md

File metadata and controls

433 lines (310 loc) · 18.6 KB

API Reference

EtherscanApi

EtherscanApi

Kind: global class

new EtherscanApi([token], [networkName])

Param Type Default Description
[token] string Etherscan API token
[networkName] string "MAIN" Network name. Available: main, ropsten, kovan and rinkeby

etherscanApi.getAccountBalance(address, [options]) ⇒ Promise.<string>

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"

etherscanApi.getAccountBalances(addresses, [options]) ⇒ Promise.<object>

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"

etherscanApi.getTransactions(address, [options]) ⇒ Promise.<Array.<object>>

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

etherscanApi.getInternalTransactions(address, [options]) ⇒ Promise.<Array.<object>>

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

etherscanApi.getInternalTransactionsByHash(txhash) ⇒ Promise.<Array.<object>>

Returns a list of 'Internal' Transactions by Address

Kind: instance method of EtherscanApi

Param Description
txhash Contract address

etherscanApi.getMinedBlocks(address, [options]) ⇒ Promise.<Array.<object>>

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

etherscanApi.getContractAbi(address) ⇒ Promsie.<Array.<object>>

Returns Contract ABI

Kind: instance method of EtherscanApi

Param
address

etherscanApi.getContractExecutionStatus(txhash) ⇒ Promise.<object>

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

etherscanApi.getTransactionStatus(txhash) ⇒ Promise.<object>

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

etherscanApi.getBlockReward(blockNumber)

Get block and uncle rewards by block number

Kind: instance method of EtherscanApi

Param Type Description
blockNumber number The number of the block

etherscanApi.getEventsLogs(address, options) ⇒ Promise.<object>

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

etherscanApi.getRecentBlockNumber() ⇒ Promise.<number>

Returns the number of the most recent block

Kind: instance method of EtherscanApi

etherscanApi.getBlockByNumber(blockNumber) ⇒ Promise.<object>

Returns information about a block by block number

Kind: instance method of EtherscanApi

Param Type Description
blockNumber number Block number

etherscanApi.getUncleByBlockNumberAndIndex(blockNumber, [index]) ⇒ Promise.<object>

Returns information about a uncle by block number and index

Kind: instance method of EtherscanApi

Param Type Default
blockNumber number
[index] number 0

etherscanApi.getBlockTransactionCount(blockNumber) ⇒ Promise.<number>

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

etherscanApi.getTransactionByHash(txhash) ⇒ Promise.<object>

Returns the information about a transaction requested by transaction hash

Kind: instance method of EtherscanApi

Param Type Description
txhash string Transaction hash

etherscanApi.getTransactionByBlockNumberAndIndex(blockNumber, [index]) ⇒ Promise.<object>

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

etherscanApi.getTransactionCount(address, [options]) ⇒ Promise.<number>

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"

etherscanApi.sendRawTransaction(hex) ⇒ Promise.<void>

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

etherscanApi.getTransactionReceipt(txhash) ⇒ Promise.<object>

Returns the receipt of a transaction by transaction hash

Kind: instance method of EtherscanApi

Param Type Description
txhash string Transaction hash

etherscanApi.call(to, data, [options]) ⇒ Promise.<string>

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"

etherscanApi.getCode(address, [options]) ⇒ Promise.<string>

Returns code at a given address

Kind: instance method of EtherscanApi

Param Type Default
address string
[options] object
[options.tag] string "latest"

etherscanApi.getStorageAt(address, position, options) ⇒ Promise.<string>

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"

etherscanApi.getGasPrice([options]) ⇒ Promise.<string>

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

etherscanApi.estimateGas(toAddress, options) ⇒ Promise.<void>

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

etherscanApi.getTokenByContractAddress(contractAddress) ⇒ Promise.<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

etherscanApi.getTotalEtherSupply() ⇒ Promise.<string>

Returns total supply of Ether

Kind: instance method of EtherscanApi

etherscanApi.getEtherLastPrice() ⇒ Promise.<object>

Returns Ether last price

Kind: instance method of EtherscanApi