etherscan/api

etherscan/api

etherscan/api

etherscan/api(apiKey: string, chain: string, timeout: number, client: object)
Parameters
apiKey (string) (optional) Your Etherscan APIkey
chain (string) (optional) Other chain keys [ropsten, rinkeby, kovan]
timeout (number) (optional) Timeout in milliseconds for requests, default 10000
client (object = null) optional axios client instance

log

log

proxy

proxy

stats

stats

block

block

transaction

transaction

contract

contract

account

account

getLogs

The Event Log API was designed to provide an alternative to the native eth_getLogs.

getLogs(address: any, fromBlock: any, toBlock: any, topic0: any, topic0_1_opr: any, topic1: any, topic1_2_opr: any, topic2: any, topic2_3_opr: any, topic3: any, topic0_2_opr: any)
Parameters
address (any)
fromBlock (any)
toBlock (any)
topic0 (any)
topic0_1_opr (any)
topic1 (any)
topic1_2_opr (any)
topic2 (any)
topic2_3_opr (any)
topic3 (any)
topic0_2_opr (any)

getLogs

returns the status of a specific transaction hash

getLogs(address: any, fromBlock: string, toBlock: string, topic0: string, topic0_1_opr: string, topic1: string, topic1_2_opr: string, topic2: string, topic2_3_opr: string, topic3: string, topic0_2_opr: string): Promise<object>
Parameters
address (any)
fromBlock (string) fromBlock
toBlock (string) toBlock
topic0 (string) topic (32 Bytes per topic)
topic0_1_opr (string) and|or between topic0 & topic1
topic1 (string) topic (32 Bytes per topic)
topic1_2_opr (string) and|or between topic1 & topic2
topic2 (string) topic (32 Bytes per topic)
topic2_3_opr (string) and|or between topic2 & topic3
topic3 (string) topic (32 Bytes per topic)
topic0_2_opr (string) and|or between topic0 & topic2
Returns
Promise<object>:
Example
https://etherscan.io/apis#logs

eth_blockNumber

Returns the number of most recent block

eth_blockNumber(): Promise<integer>
Returns
Promise<integer>:
Example
var block = api.proxy.eth_blockNumber();

eth_getBlockByNumber

Returns information about a block by block number.

eth_getBlockByNumber(tag: string): Promise<integer>
Parameters
tag (string) Tag to look up
Returns
Promise<integer>:
Example
var blockNumber = api.proxy.eth_getBlockByNumber('0x10d4f');

eth_getUncleByBlockNumberAndIndex

Returns information about a uncle by block number.

eth_getUncleByBlockNumberAndIndex(tag: string, index: string): Promise<object>
Parameters
tag (string) Tag to look up
index (string) Index
Returns
Promise<object>:
Example
var res = api.proxy.eth_getUncleByBlockNumberAndIndex('0x210A9B', '0x0');

eth_getBlockTransactionCountByNumber

Returns the number of transactions in a block from a block matching the given block number

eth_getBlockTransactionCountByNumber(tag: string): Promise<object>
Parameters
tag (string) Tag to look up
Returns
Promise<object>:
Example
var res = api.proxy.eth_getBlockTransactionCountByNumber('0x10FB78');

eth_getTransactionByHash

Returns the information about a transaction requested by transaction hash

eth_getTransactionByHash(txhash: any, hash: string): Promise<object>
Parameters
txhash (any)
hash (string) Transaction hash
Returns
Promise<object>:
Example
var res = api.proxy.eth_getTransactionByHash('0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1');

eth_getTransactionByBlockNumberAndIndex

Returns information about a transaction by block number and transaction index position

eth_getTransactionByBlockNumberAndIndex(tag: string, index: string): Promise<object>
Parameters
tag (string) Tag to look up
index (string) Index
Returns
Promise<object>:
Example
var res = api.proxy.eth_getTransactionByBlockNumberAndIndex('0x10d4f', '0x0');

eth_getTransactionCount

Returns the number of transactions sent from an address

eth_getTransactionCount(address: string): Promise<object>
Parameters
address (string) Address of the transaction
Returns
Promise<object>:
Example
var res = api.proxy.eth_getTransactionCount('0x2910543af39aba0cd09dbb2d50200b3e800a63d2', 'latest');

eth_sendRawTransaction

Creates new message call transaction or a contract creation for signed transactions

eth_sendRawTransaction(hex: string): Promise<object>
Parameters
hex (string) Serialized Message
Returns
Promise<object>:
Example
var res = api.proxy.eth_sendRawTransaction('0xf904808000831cfde080');

eth_getTransactionReceipt

Returns the receipt of a transaction by transaction hash

eth_getTransactionReceipt(txhash: string): Promise<object>
Parameters
txhash (string) Transaction hash
Returns
Promise<object>:
Example
var ret = api.proxy.eth_getTransactionReceipt('0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1');

eth_call

Executes a new message call immediately without creating a transaction on the block chain

eth_call(to: string, data: string, tag: string): Promise<object>
Parameters
to (string) Address to execute from
data (string) Data to transfer
tag (string) A tag
Returns
Promise<object>:
Example
var res = api.proxy.eth_call('0xAEEF46DB4855E25702F8237E8f403FddcaF931C0', '0x70a08231000000000000000000000000e16359506c028e51f16be38986ec5746251e9724', 'latest');

eth_getCode

Returns code at a given address

eth_getCode(address: string, tag: string): Promise<object>
Parameters
address (string) Address to get code from
tag (string) ??
Returns
Promise<object>:
Example
var res = api.proxy.eth_getCode('0xf75e354c5edc8efed9b59ee9f67a80845ade7d0c',  'latest');

eth_getStorageAt

Returns the value from a storage position at a given address.

eth_getStorageAt(address: string, position: string, tag: string): Promise<object>
Parameters
address (string) Address to get code from
position (string) Storage position
tag (string) ??
Returns
Promise<object>:
Example
var res = api.proxy.eth_getStorageAt('0x6e03d9cce9d60f3e9f2597e13cd4c54c55330cfd', '0x0',  'latest');

eth_gasPrice

Returns the current price per gas in wei. var gasprice = api.proxy.eth_gasPrice();

eth_gasPrice(): Promise<object>
Returns
Promise<object>:

eth_estimateGas

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

eth_estimateGas(to: string, value: string, gasPrice: string, gas: string): Promise<object>
Parameters
to (string) Address to get code from
value (string) Storage position
gasPrice (string) ??
gas (string) ??
Returns
Promise<object>:

tokensupply

Returns the supply of Tokens

tokensupply(tokenname: string, contractaddress: string): Promise<object>
Parameters
tokenname (string) Name of the Token
contractaddress (string) Address from token contract
Returns
Promise<object>:
Example
var supply = api.stats.tokensupply(null, '0x57d90b64a1a57749b0f932f1a3395792e12e7055');

ethsupply

Returns total supply of ether var supply = api.stats.ethsupply();

ethsupply(): Promise<integer>
Returns
Promise<integer>:

ethprice

Returns the price of ether now

ethprice(): Promise<integer>
Returns
Promise<integer>:
Example
var price = api.stats.ethprice();

getblockreward

Find the block reward for a given address and block

getblockreward(address: string, blockno: string): Promise<object>
Parameters
address (string) Address of the block
blockno (string) Block number
Returns
Promise<object>:

getstatus

returns the status of a specific transaction hash

getstatus(txhash: string): Promise<object>
Parameters
txhash (string) Transaction hash
Returns
Promise<object>:

getabi

Returns the ABI/Interface of a given contract

getabi(address: string): Promise<object>
Parameters
address (string) Contract address
Returns
Promise<object>:
Example
api.contract
 .getabi('0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413')
 .then(console.log)

getsourcecode

Returns the Sourcecode of a given verified contract

getsourcecode(address: string): Promise<object>
Parameters
address (string) Contract address
Returns
Promise<object>:
Example
api.contract
 .getsourcecode('0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413')
 .then(console.log)

tokenbalance

Returns the amount of Tokens a specific account owns.

tokenbalance(address: string, tokenname: string, contractaddress: string): Promise<object>
Parameters
address (string) Contract address
tokenname (string) Name of the token
contractaddress (string) Contract address
Returns
Promise<object>:
Example
var supply = api.account.tokenbalance(
      '0x4366ddc115d8cf213c564da36e64c8ebaa30cdbd',
      '',
      '0xe0b7927c4af23765cb51314a0e0521a9645f0e2a' // DGD contract address
);

balance

Returns the balance of a sepcific account

balance(address: string): Promise<object>
Parameters
address (string) Address
Returns
Promise<object>:
Example
var balance = api.account.balance('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae');

txlistinternal

Get a list of internal transactions

txlistinternal(txhash: string, address: string, startblock: string, endblock: string, sort: string): Promise<object>
Parameters
txhash (string) Transaction hash. If specified then address will be ignored
address (string) Transaction address
startblock (string) start looking here
endblock (string) end looking there
sort (string) Sort asc/desc
Returns
Promise<object>:
Example
var txlist = api.account.txlistinternal('0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170');

txlist

Get a list of transactions for a specfic address

txlist(address: string, startblock: string, endblock: string, page: number, offset: number, sort: string): Promise<object>
Parameters
address (string) Transaction address
startblock (string) start looking here
endblock (string) end looking there
page (number) Page number
offset (number) Max records to return
sort (string) Sort asc/desc
Returns
Promise<object>:
Example
var txlist = api.account.txlist('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae', 1, 'latest', 1, 100, 'asc');

getminedblocks

Get a list of blocks that a specific account has mineds

getminedblocks(address: string)
Parameters
address (string) Transaction hash
Example
var txlist = api.account.getminedblocks('0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b');

tokentx

[BETA] Get a list of "ERC20 - Token Transfer Events" by Address

tokentx(address: string, contractaddress: string, startblock: string, endblock: string, page: number, offset: number, sort: string): Promise<object>
Parameters
address (string) Account address
contractaddress (string) Address of ERC20 token contract (if not specified lists transfers for all tokens)
startblock (string) start looking here
endblock (string) end looking there
page (number) Page number
offset (number) Max records to return
sort (string) Sort asc/desc
Returns
Promise<object>:
Example
var txlist = api.account.tokentx('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae', '0x5F988D968cb76c34C87e6924Cc1Ef1dCd4dE75da', 1, 'latest', 'asc');

tokennfttx

[BETA] Get a list of "ERC721 - Token Transfer Events" by Address

tokennfttx(address: string, contractaddress: string, startblock: string, endblock: string, page: number, offset: number, sort: string): Promise<object>
Parameters
address (string) Account address
contractaddress (string) Address of ERC721 token contract (if not specified lists transfers for all tokens)
startblock (string) start looking here
endblock (string) end looking there
page (number) Page number
offset (number) Max records to return
sort (string) Sort asc/desc
Returns
Promise<object>:
Example
var txlist = api.account.tokenftntx('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae', '0x5F988D968cb76c34C87e6924Cc1Ef1dCd4dE75da', 1, 'latest', 'asc');

pickChainUrl

gets the correct urls of the backend

pickChainUrl(chain: string): any
Parameters
chain (string)
Returns
any: Url of backend

get-request

get-request(chain: string, timeout: number, client: object): string
Parameters
chain (string)
timeout (number)
client (object)
Returns
string:

getRequest

getRequest(query: any): Promise<any>
Parameters
query (any)
Returns
Promise<any>: