routescan-client
Version:
A set of classes to work with evm-compatible blockchain observers
1,599 lines (1,589 loc) • 52.8 kB
TypeScript
import { AxiosResponse, AxiosRequestConfig } from 'axios';
declare enum BlockExplorerType {
Routescan = "routescan",
Ethereum = "ethereum"
}
declare enum Chain {
NotSpecified = 0,
Ethereum = 1,
EthereumGoerli = 5,
EthereumHolesky = 17000,
EthereumSepolia = 11155111,
Optimism = 10,
OptimismGoerli = 420,
OptimismSepolia = 11155420,
FlareMainnet = 14,
FlareTestnet = 114,
Cronos = 25,
CronosTestnet = 338,
BinanceSmartChain = 56,
BinanceSmartChainTestnet = 97,
BinanceOpBnbMainnet = 204,
BinanceOpBnbTestnet = 5611,
Polygon = 137,
PolygonMumbai = 80001,
PolygonAmoy = 80002,
Mint = 185,
MintSepolia = 1687,
Fantom = 250,
FantomTestnet = 4002,
Filecoin = 314,
ZkSyncEra = 324,
Mantle = 5000,
MantleSepolia = 5003,
Base = 8453,
BaseGoerli = 84531,
BaseSepolia = 84532,
Arbitrum = 42161,
ArbitrumNova = 42170,
ArbitrumGoerli = 421613,
ArbitrumSepolia = 421614,
AvalancheCChain = 43114,
AvalancheCChainFuji = 43113,
Celo = 42220,
CeloAlfajores = 44787,
Linea = 59144,
LineaGoerli = 59140,
LineaSepolia = 59141,
Taiko = 167000,
TaikoHeklaL2 = 167009,
Dexalot = 432204,
DexalotTestnet = 432201,
Palm = 11297108109,
PalmTestnet = 11297108099
}
interface ChainItem {
id: Chain;
blockExplorerType: BlockExplorerType;
blockExplorerUrl: string;
}
declare enum BlockExplorerModule {
Account = "account",
Block = "block",
Contract = "contract",
Logs = "logs",
Proxy = "proxy",
Transaction = "transaction"
}
declare enum BlockExplorerAction {
Balance = "balance",
BalanceMulti = "balancemulti",
GetBlockByTime = "getblocknobytime",
GetBlockCountdown = "getblockcountdown",
GetLogs = "getLogs",
TokenBalance = "tokenbalance",
TxList = "txlist",
TokenTxList = "tokentx",
TxListInternal = "txlistinternal",
eth_blockNumber = "eth_blockNumber",
eth_getBlockByNumber = "eth_getBlockByNumber",
eth_getUncleByBlockNumberAndIndex = "eth_getUncleByBlockNumberAndIndex",
eth_getBlockTransactionCountByNumber = "eth_getBlockTransactionCountByNumber",
eth_getTransactionByHash = "eth_getTransactionByHash",
eth_getTransactionByBlockNumberAndIndex = "eth_getTransactionByBlockNumberAndIndex",
eth_getTransactionCount = "eth_getTransactionCount",
eth_sendRawTransaction = "eth_sendRawTransaction",
eth_getTransactionReceipt = "eth_getTransactionReceipt",
eth_call = "eth_call",
eth_getCode = "eth_getCode",
eth_getStorageAt = "eth_getStorageAt",
eth_gasPrice = "eth_gasPrice",
eth_estimateGas = "eth_estimateGas",
GetStatus = "getstatus",
GetTexReceiptStatus = "gettxreceiptstatus",
VerifySourceCode = "verifysourcecode"
}
declare enum BlockExplorerTag {
Earliest = "earliest",
Pending = "pending",
Latest = "latest"
}
declare enum BlockExplorerStatus {
Success = "1",
Fail = "0"
}
declare enum BlockExplorerSort {
Asc = "asc",
Desc = "desc"
}
declare enum BlockExplorerClosest {
Before = "before",
After = "after"
}
declare enum BlockExplorerTopicOperation {
And = "and",
Or = "or"
}
declare enum BlockExplorerCodeFormat {
SoliditySingleFile = "solidity-single-file",
SolidityStandardJsonInput = "solidity-standard-json-input"
}
interface BlockExplorerTxCore {
/**
* @description Tx initiator address
* @example '0x4458f86353b4740fe9e09071c23a7437640063c9'
*/
from: string;
/**
* @description To address
* @example '0xbf3403210f9802205f426759947a80a9fda71b1e'
*/
to: string;
/**
* @description Input data
* @example '0x'
*/
input: string;
}
interface BlockTransaction extends BlockExplorerTxCore {
/**
* @description Block hash
* @example '0x7eb7c23a5ac2f2d70aa1ba4e5c56d89de5ac993590e5f6e79c394e290d998ba8'
*/
blockHash: string;
/**
* @description Block number in hex
* @example '0x10d4f'
*/
blockNumber: string;
/**
* @description Gas count in hex
* @example '0x5208'
*/
gas: string;
/**
* @description Gas price in hex
* @example '0xba43b7400'
*/
gasPrice: string;
/**
* @description Tx hash
* @example '0xa442249820de6be754da81eafbd44a865773e4b23d7c0522d31fd03977823008'
*/
hash: string;
/**
* @description Nonce in hex
* @example '0x1'
*/
nonce: string;
/**
* @description Tx index
* @example '0x0'
*/
transactionIndex: string;
/**
* @description Amount value in hex
* @example '0xaa9f075c200000'
*/
value: string;
/**
* @description Type
* @example '0x0'
*/
type: string;
/**
* @description V
* @example '0x1b'
*/
v: string;
/**
* @description R
* @example '0x2c2789c6704ba2606e200e1ba4fd17ba4f0e0f94abe32a12733708c3d3442616'
*/
r: string;
/**
* @description S
* @example '0x2946f47e3ece580b5b5ecb0f8c52604fa5f60aeb4103fc73adcbf6d620f9872b'
*/
s: string;
}
interface BlockExplorerTxBase extends BlockExplorerTxCore {
/**
* @description Block number string
* @example '47884'
*/
blockNumber: string;
/**
* @description Block generation timestamp in seconds
* @example '1438947953'
*/
timeStamp: string;
/**
* @description Value in wei
* @example '5000000000000000000'
*/
value: string;
/**
* @description Contract address
* @example ''
*/
contractAddress: string;
/**
* @description Gas restriction
* @example '23000'
*/
gas: string;
/**
* @description Used gas amount
* @example '21612'
*/
gasUsed: string;
/**
* @description Error code ("0" if all ok)
* @example '0'
*/
isError?: string;
}
interface BlockExplorerTxCommon extends BlockExplorerTxBase {
/**
* @description Transaction hash
* @example '0xad1c27dd8d0329dbc400021d7477b34ac41e84365bd54b45a4019a15deb10c0d'
*/
hash: string;
}
interface BlockExplorerTransaction extends BlockExplorerTxCommon {
/**
* @description From address nonce
* @example '0'
*/
nonce: string;
/**
* @description Block hash string
* @example '0xf2988b9870e092f2898662ccdbc06e0e320a08139e9c6be98d0ce372f8611f22'
*/
blockHash: string;
/**
* @description Transaction index
* @example '0'
*/
transactionIndex: string;
/**
* @description Gas price in wei
* @example '400000000000'
*/
gasPrice: string;
/**
* @description Tx receipt status
* @example '1'
*/
txreceipt_status: string;
/**
* @description Cumulative gas used
* @example '21612'
*/
cumulativeGasUsed: string;
/**
* @description Block confirmations count
* @example '19292464'
*/
confirmations: string;
/**
* @description Method id
* @example '0x454e3435'
*/
methodId: string;
/**
* @description Function name
* @example ''
*/
functionName: string;
}
interface BlockExplorerTxInternal extends BlockExplorerTxCommon {
/**
* @description Tx type
* @example 'call'
*/
type: string;
/**
* @description Trace id
* @example '1'
*/
traceId: string;
/**
* @description Error code
* @example ''
*/
errCode: string;
}
interface BlockExplorerTxInternalByTxHash extends BlockExplorerTxBase {
/**
* @description Tx type
* @example 'call'
*/
type: string;
/**
* @description Error code
* @example ''
*/
errCode: string;
}
interface BlockExplorerErc20TokenTransferEvent extends BlockExplorerTxCommon {
/**
* @description From address nonce
* @example '0'
*/
nonce: string;
/**
* @description Block hash string
* @example '0xf2988b9870e092f2898662ccdbc06e0e320a08139e9c6be98d0ce372f8611f22'
*/
blockHash: string;
/**
* @description Transaction index
* @example '0'
*/
transactionIndex: string;
/**
* @description Cumulative gas used
* @example '21612'
*/
cumulativeGasUsed: string;
/**
* @description Gas price in wei
* @example '400000000000'
*/
gasPrice: string;
/**
* @description Block confirmations count
* @example '19292464'
*/
confirmations: string;
/**
* @description Token name
* @example 'TetherToken'
*/
tokenName: string;
/**
* @description Token symbol
* @example 'USDt'
*/
tokenSymbol: string;
/**
* @description Token decimal count
* @example '6'
*/
tokenDecimal: string;
}
interface BlockExplorerTxRpc extends BlockTransaction {
/**
* @description Max fee per gas
* @example '0x1f6ea08600'
*/
maxFeePerGas: string;
/**
* @description Max priority fee per gas
* @example '0x3b9aca00'
*/
maxPriorityFeePerGas: string;
/**
* @description Access list
*/
accessList: any[];
/**
* @description Chain id
* @example '0x1'
*/
chainId: string;
/**
* @description Y parity
* @example '0x0'
*/
yParity: string;
}
interface BlockExplorerTxReceiptLog {
/**
* @description Address
* @example '0xdac17f958d2ee523a2206206994597c13d831ec7'
*/
address: string;
/**
* @description Topics list
* @example ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef']
*/
topics: string[];
/**
* @description Log data
* @example '0x00000000000000000000000000000000000000000000000000000000013f81a6'
*/
data: string;
/**
* @description Block number
* @example '0xcf2427'
*/
blockNumber: string;
/**
* @description Transaction hash
* @example '0xadb8aec59e80db99811ac4a0235efa3e45da32928bcff557998552250fa672eb'
*/
transactionHash: string;
/**
* @description Transaction index
* @example '0x122'
*/
transactionIndex: string;
/**
* @description Block hash
* @example '0x07c17710dbb7514e92341c9f83b4aab700c5dba7c4fb98caadd7926a32e47799'
*/
blockHash: string;
/**
* @description Log index
* @example '0xdb'
*/
logIndex: string;
/**
* @description Removed status
* @example false
*/
removed: boolean;
}
interface BlockExplorerTxReceipt {
/**
* @description From address
* @example '0x292f04a44506c2fd49bac032e1ca148c35a478c8'
*/
from: string;
/**
* @description To address
* @example '0xdac17f958d2ee523a2206206994597c13d831ec7'
*/
to: string;
/**
* @description Block hash
* @example '0x07c17710dbb7514e92341c9f83b4aab700c5dba7c4fb98caadd7926a32e47799'
*/
blockHash: string;
/**
* @description Block number
* @example '0xcf2427'
*/
blockNumber: string;
/**
* @description Contract address
* @example null
*/
contractAddress: string | null;
/**
* @description Cumulative gas used in hex
* @example '0xeb67d5'
*/
cumulativeGasUsed: string;
/**
* @description Effective gas price in hex
* @example '0x1a96b24c26'
*/
effectiveGasPrice: string;
/**
* @description Gas used in hex
* @example '0xb41d'
*/
gasUsed: string;
/**
* @description Receipt logs
*/
logs: BlockExplorerTxReceiptLog[];
/**
* @description Logs bloom
* @example '0x00000000000000000000000000000000000000000000000000000000000004000000000004000000000000000000010000000000000000000000000000000000000000000000000000000008000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000010000000001100000000000000000000000000000000000000000000000000000200100000000000000000000000000080000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
*/
logsBloom: string;
/**
* @description Status
* @example '0x1'
*/
status: string;
/**
* @description Transaction hash
* @example '0xadb8aec59e80db99811ac4a0235efa3e45da32928bcff557998552250fa672eb'
*/
transactionHash: string;
/**
* @description Transaction index
* @example '0x122'
*/
transactionIndex: string;
/**
* @description Tx type
* @example '0x2'
*/
type: string;
}
interface BlockExplorerTxStatus {
isError?: string;
errDescription?: string;
}
interface BlockExplorerReceiptStatus {
status: BlockExplorerStatus;
}
interface BlockWithdrawal {
/**
* @description Withdrawal index
* @example '0x3e8bd6b'
*/
index: string;
/**
* @description Validation index
* @example '0xc208b'
*/
validatorIndex: string;
/**
* @description Withdrawal address
* @example '0xacb8f83bdf5c6e6ba39b2eed03b856820c5ff775'
*/
address: string;
/**
* @description Amount in hex
* @example '0x1282722'
*/
amount: string;
}
interface BlockExplorerBlockCommon {
/**
* @description Base fee per gas in hex
* @example '0x1bf871922'
*/
baseFeePerGas: string;
/**
* @description Difficulty in hex
* @example '0x0'
*/
difficulty: string;
/**
* @description Extra data
* @example '0x546974616e2028746974616e6275696c6465722e78797a29'
*/
extraData: string;
/**
* @description Gas limit in hex
* @example '0x1c9c380'
*/
gasLimit: string;
/**
* @description Gas used in hex
* @example '0xbed51e'
*/
gasUsed: string;
/**
* @description Tx hash
* @example '0xed01764ce15493d3ffb3bed8728aa2ab3eeaba1ac4809853ff26604a7c4c6bc8'
*/
hash: string;
/**
* @description Logs bloom
* @example '0x96217cfee9850656fc89506684b151d5404b43208cf290ac3b49010247b80b09d0986266d749d0c4d0b90c15f8fec71c4b6bec6ddb7732d75545ca2573ac8f52a11c94ae7272c8886c00e38fbaa123e14545933541674f1a072a1c5f8f2f30848b4b6150077c4367a01ed9d1f990ee190621e84832192ee1bec7519c1d4d8ee5766bdf49c5f1f15b2459d360a0e2844174045db3f13ab36d2d292546b6727c2887ed026f14116d1b115fe9fc35837dd0645795b7306630e8c9e10a0a411d58e105f06716843a70d4854be88213ca09b746f6345f95a6099c652752cee894f0f28479b831c3a10078074d1ecbe4880b460a7d502b74ffb6ca28c03cb06551e70b'
*/
logsBloom: string;
/**
* @description Miner address
* @example '0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97'
*/
miner: string;
/**
* @description Mix hash
* @example '0x67260293c49e5358141cc149273dea3df7ce83541a8d449abfbc7fd0f67418b5'
*/
mixHash: string;
/**
* @description Nonce in hex
* @example '0x0000000000000000'
*/
nonce: string;
/**
* @description Block number in hex
* @example '0x1427aa8'
*/
number: string;
/**
* @description Parent hash
* @example '0x62c917e120a3927690b18d7ca6e8476b964973e5cdc249b65397badf985e034d'
*/
parentHash: string;
/**
* @description Receipts root
* @example '0x47c47c1fe77de06ee773ef654b05cf5ca6d89b1c6158c71c521a5d4936be7111'
*/
receiptsRoot: string;
/**
* @description Sha3 uncles
* @example '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
*/
sha3Uncles: string;
/**
* @description Size in hex
* @example '0x10370'
*/
size: string;
/**
* @description State root
* @example '0x39240235baacb1edbee97d72208af1d92fca083325920f8f1627422b5b3bcb25'
*/
stateRoot: string;
/**
* @description Block timestamp in hex
* @example '0x672c5e5b'
*/
timestamp: string;
/**
* @description Txs root
* @example '0xaa3fbdf01f0acc26257824177ac0d0e909040608b600991781c95506d1657f81'
*/
transactionsRoot: string;
/**
* @description Uncles list
*/
uncles: any[];
}
interface BlockExplorerBlockUncleItem extends BlockExplorerBlockCommon {
}
interface BlockExplorerBlockItem extends BlockExplorerBlockCommon {
/**
* @description Blob gas used in hex
* @example '0x60000'
*/
blobGasUsed: string;
/**
* @description Excess blob gas in hex
* @example '0x2ea0000'
*/
excessBlobGas: string;
/**
* @description Parent beacon block root
* @example '0x1b25dae6ad3c6fe004eeac0d3385b2ac2dc68d765545c1e06f0cbf75896bad86'
*/
parentBeaconBlockRoot: string;
/**
* @description Total difficulty in hex
* @example '0xc70d815d562d3cfa955'
*/
totalDifficulty: string;
/**
* @description Txs list
*/
transactions: (string | BlockTransaction)[];
/**
* @description Block withdrawals list
*/
withdrawals: BlockWithdrawal[];
/**
* @description Withdrawals root
* @example '0xf1751aa5d2f0b24fd84ee1b8d5e550f0f7a4f7089160d8699e12e30b2b1218c0'
*/
withdrawalsRoot: string;
}
interface BlockCountdownTime {
/**
* @description Current block id
* @example '19419956'
*/
CurrentBlock: string;
/**
* @description Countdown block
* @example '167015880000'
*/
CountdownBlock: string;
/**
* @description Remaining block
* @example '166996460044'
*/
RemainingBlock: string;
/**
* @description Estimate time in sec
* @example 2003957520528
*/
EstimateTimeInSec: string;
}
interface BlockExplorerResponseCommon {
/**
* @description Status string (0 - fail, 1 - success)
*/
status: BlockExplorerStatus;
/**
* @description Status message (**OK** if success)
*/
message: string;
}
interface BlockExplorerBlockCountdownTimeResponse extends BlockExplorerResponseCommon {
result: BlockCountdownTime;
}
interface BlockExplorerBlockIdResponse extends BlockExplorerResponseCommon {
/**
* @description Block id string
*/
result: string;
}
interface GetAccountBalanceResponse extends BlockExplorerResponseCommon {
/**
* @description Account balance in wei
* @example '40891626854930000000999'
*/
result: string;
}
interface GetAccountsBalanceResponse extends BlockExplorerResponseCommon {
result: {
/**
* @description Account address
* @example '0xddBd2B932c763bA5b1b7AE3B362eac3e8d40121A'
*/
account: string;
/**
* @description Account balance in wei
* @example '40891626854930000000999'
*/
balance: string;
}[];
}
interface GetAccountTokenBalanceResponse extends BlockExplorerResponseCommon {
/**
* @description Token balance for specified address in wei (probably, depends on token parameters)
*/
result: string;
}
interface EventLog {
/**
* @description Smart-contract address
* @example '0x9e66eba102b77fc75cd87b5e60141b85573bc8e8'
*/
address: string;
/**
* @description Event topics array
* @example [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000007d01c6a9f637f7f2a35b9797274d6b98c41e11e7",
"0x0000000000000000000000000000000000000000000000000000000000e4e9c7"
]
*/
topics: string[];
/**
* @description Tx data
* @example '0x'
*/
data: string;
/**
* @description Tx block number
* @example '0x2349342'
*/
blockNumber: string;
/**
* @description Tx block hash
* @example '0x45d6a3318d1b7e44525b1058ec6dd3863c71c2dc0dd28e4b326d92964600bae0'
*/
blockHash: string;
/**
* @description Tx timestamp
* @example '0x653c1480'
*/
timeStamp: string;
/**
* @description Tx gas price in wei
* @example '0x6fc23ac00'
*/
gasPrice: string;
/**
* @description Tx gas used
* @example '0x26cee'
*/
gasUsed: string;
/**
* @description Log index
* @example '0x2'
*/
logIndex: string;
/**
* @description Tx hash
* @example '0x08042351a9cb68419d44fc3c905f880bfb005c271773543c2cd80191826f6306'
*/
transactionHash: string;
/**
* @description Tx index
* @example '0x2'
*/
transactionIndex: string;
}
interface GetEventLogsByAddressResponse extends BlockExplorerResponseCommon {
result: EventLog[];
}
type GetEventLogsByTopicsResponse = GetEventLogsByAddressResponse;
type GetEventLogsByAddressFilteredResponse = GetEventLogsByAddressResponse;
interface BlockExplorerTxListResponse extends BlockExplorerResponseCommon {
/**
* @description List of tx objects
*/
result: BlockExplorerTransaction[];
}
interface BlockExplorerInternalTxListResponse extends BlockExplorerResponseCommon {
/**
* @description List of internal tx objects
*/
result: BlockExplorerTxInternal[];
}
interface BlockExplorerInternalTxListByHashResponse extends BlockExplorerResponseCommon {
/**
* @description List of internal tx objects
*/
result: BlockExplorerTxInternalByTxHash[];
}
interface GetErc20TokenTransferEventsListResponse extends BlockExplorerResponseCommon {
result: BlockExplorerErc20TokenTransferEvent[];
}
interface BlockExplorerRpcResponseCommon {
/**
* @description RPC version
* @example '2.0'
*/
jsonrpc: string;
/**
* @description ???
* @example 83
*/
id: number;
error?: {
/**
* @description Error code
* @example -32000
*/
code: number;
/**
* @description Error message
* @example 'rlp: value size exceeds available input length'
*/
message: string;
};
}
interface BlockExplorerEthBlockNumberResponse extends BlockExplorerRpcResponseCommon {
/**
* @description Recent block number in hex
* @example '0x1427a5f'
*/
result?: string;
}
interface BlockExplorerEthBlockByNumberResponse extends BlockExplorerRpcResponseCommon {
result?: BlockExplorerBlockItem;
}
interface BlockExplorerEthUncleByBlockNumberAndIndexResponse extends BlockExplorerRpcResponseCommon {
result?: BlockExplorerBlockUncleItem;
}
interface BlockExplorerEthBlockTransactionCountByNumberResponse extends BlockExplorerRpcResponseCommon {
result?: string;
}
interface BlockExplorerEthTransactionByHashResponse extends BlockExplorerRpcResponseCommon {
result?: BlockExplorerTxRpc;
}
interface BlockExplorerEthTransactionByBlockNumberAndIndexResponse extends BlockExplorerRpcResponseCommon {
result?: BlockExplorerTxRpc;
}
interface BlockExplorerEthTransactionCountResponse extends BlockExplorerRpcResponseCommon {
result?: string;
}
interface BlockExplorerEthSendRawTransactionResponse extends BlockExplorerRpcResponseCommon {
result?: string;
}
interface BlockExplorerEthGetTransactionReceiptResponse extends BlockExplorerRpcResponseCommon {
result?: BlockExplorerTxReceipt;
}
interface BlockExplorerEthCallResponse extends BlockExplorerRpcResponseCommon {
result?: string;
}
interface BlockExplorerEthGetCodeResponse extends BlockExplorerRpcResponseCommon {
result?: string;
}
interface BlockExplorerEthGetStorageAtResponse extends BlockExplorerRpcResponseCommon {
result?: string;
}
interface BlockExplorerEthGasPriceResponse extends BlockExplorerRpcResponseCommon {
result?: string;
}
interface BlockExplorerEthEstimateGasResponse extends BlockExplorerRpcResponseCommon {
result?: string;
}
interface BlockExplorerContractExecutionStatusResponse extends BlockExplorerResponseCommon {
result: BlockExplorerTxStatus;
}
interface BlockExplorerTransactionReceiptStatusResponse extends BlockExplorerResponseCommon {
result: BlockExplorerReceiptStatus;
}
interface BlockExplorerVerifySoliditySourceCodeResponse extends BlockExplorerResponseCommon {
/**
* @description Verify result
* @example 'a7lpxkm9kpcpicx7daftmjifrfhiuhf5vqqnawhkfhzfrcpnxj'
*/
result: string;
}
interface PaginationOptions {
/**
* @description The integer page number, if pagination is enabled
*/
page?: number;
/**
* @description The number of records displayed per page
*/
offset?: number;
}
interface BlockOptions {
/**
* @description The integer block number to start searching for records
* @example 0
*/
startblock?: number;
/**
* @description The integer block number to stop searching for records
* @example 270257
*/
endblock?: number;
/**
* @description The sorting preference, use **asc** to sort by ascending and **desc** to sort by descending
*/
sort?: BlockExplorerSort;
}
interface GetBlockCountdownTimeOptions {
/**
* @description The integer block number to estimate time remaining to be mined
* @example 16701588000
*/
blockno: number;
}
interface GetBlockNumberByTimestampOptions {
/**
* @description The closest available block to the provided timestamp, either **before** or **after**
*/
closest?: BlockExplorerClosest;
/**
* @description The integer representing the Unix timestamp in seconds
*/
timestamp: number;
}
interface GetAccountBalanceOptions {
/**
* @description The **string** representing the address to check for balance
*/
address: string;
/**
* @description The string pre-defined block parameter, either **earliest**, **pending** or **latest**
*/
tag: BlockExplorerTag;
}
/**
* @description Same as GetAccountBalanceOptions but in address option we can provide multiple addresses delimited by commas
*/
interface GetAccountsBalanceOptions extends GetAccountBalanceOptions {
}
interface GetAccountTokenBalanceOptions {
/**
* @description The **contract address** of the ERC-20 token
*/
contractAddress: string;
/**
* @description The string representing the address to check for token balance
*/
address: string;
/**
* @description The string pre-defined block parameter, either **earliest**, **pending** or **latest**
*/
tag: BlockExplorerTag;
}
interface GetEventLogsByAddressOptions extends PaginationOptions {
/**
* @description The integer block number to start searching for logs eg. 37000000
* @example 37000000
*/
fromBlock: number;
/**
* @description The integer block number to stop searching for logs eg. 37200000
* @example 37200000
*/
toBlock: number;
/**
* @description The string representing the address to check for logs
* @example '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7'
*/
address?: string;
}
interface GetEventLogsByTopicsOptions extends PaginationOptions {
/**
* @description The integer block number to start searching for logs eg. 37000000
* @example 37000000
*/
fromBlock: number;
/**
* @description The integer block number to stop searching for logs eg. 37200000
* @example 37200000
*/
toBlock: number;
/**
* @description The topic numbers to search for limited to **topic0**, **topic1**, **topic2**, **topic3**
* @example '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
*/
topic0?: string;
/**
* @description The topic operator when multiple topic combinations are used limited to **and** or **or**
* @example 'and'
*/
topic0_1_opr?: BlockExplorerTopicOperation;
/**
* @description The topic numbers to search for limited to **topic0**, **topic1**, **topic2**, **topic3**
*/
topic1?: string;
/**
* @description The topic numbers to search for limited to **topic0**, **topic1**, **topic2**, **topic3**
*/
topic2?: string;
/**
* @description The topic numbers to search for limited to **topic0**, **topic1**, **topic2**, **topic3**
*/
topic3?: string;
}
interface GetEventLogsByAddressFilteredOptions extends GetEventLogsByTopicsOptions {
/**
* @description The string representing the address to check for logs
* @example '0x9e66eba102b77fc75cd87b5e60141b85573bc8e8'
*/
address?: string;
}
interface GetNormalTxListByAddressOptions extends PaginationOptions, BlockOptions {
/**
* @description The string representing the addresses to get corresponding txs
* @example '0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3'
*/
address: string;
}
type GetInternalTxListByAddressOptions = GetNormalTxListByAddressOptions;
interface GetInternalTxListByTxHashOptions {
/**
* @description The string representing the transaction hash to check for internal transactions
* @example '0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170'
*/
txhash: string;
}
interface GetErc20TokenTransferEventsListOptions extends PaginationOptions, BlockOptions {
/**
* @description The string representing the address to check for balance
@example '0x77134cbC06cB00b66F4c7e623D5fdBF6777635EC'
*/
address?: string;
/**
* @description The string representing the token contract address to check for balance
* @example '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7'
*/
contractaddress: string;
}
interface GetEthBlockByNumberOptions {
/**
* The block number, in hex
* @example '0x10d4f'
*/
tag?: string;
/**
* @description The boolean value to show full transaction objects.
when **true**, returns full transaction objects and their information,
when **false** only returns a list of transactions.
*/
boolean: boolean;
}
interface GetEthUncleByBlockNumberAndIndexOptions {
/**
* The block number, in hex
* @example '0x10d4f'
*/
tag?: string;
/**
* @description Position of the uncle's index in the block, in hex
* @example '0x5'
*/
index?: string;
}
interface GetEthBlockTransactionCountByNumberOptions {
/**
* The block number, in hex
* @example '0x10d4f'
*/
tag?: string;
}
interface GetEthTransactionByHashOptions {
txhash: string;
}
interface GetEthTransactionByBlockNumberAndIndexOptions {
/**
* @description The block number, in hex
* @example '0x10FB78'
*/
tag: string;
/**
* @description The position of the uncle's index in the block, in hex
* @example '0x0'
*/
index?: string;
}
interface GetEthTransactionCountOptions {
/**
* @description The string representing the address to get transaction count
* @example '0x4bd5900Cb274ef15b153066D736bf3e83A9ba44e'
*/
address: string;
/**
* @description The string pre-defined block parameter, either **earliest**, **pending** or **latest**
* @example 'latest'
*/
tag?: BlockExplorerTag;
}
interface GetEthSendRawTransactionOptions {
/**
* @description The string representing the signed raw transaction data to broadcast
* @example '0xf904808000831cfde080'
*/
hex: string;
}
interface GetEthTransactionReceiptOptions {
/**
* @description The string representing the hash of the transaction
* @example '0xadb8aec59e80db99811ac4a0235efa3e45da32928bcff557998552250fa672eb'
*/
txhash: string;
}
interface GetEthCallOptions {
/**
* @description The string representing the address to interact with
* @example '0xAEEF46DB4855E25702F8237E8f403FddcaF931C0'
*/
to: string;
/**
* @description The hash of the method signature and encoded parameters
* @example '0x70a08231000000000000000000000000e16359506c028e51f16be38986ec5746251e9724'
*/
data?: string;
/**
* @description The string pre-defined block parameter, either **earliest**, **pending** or **latest**
*/
tag?: BlockExplorerTag;
}
interface GetEthCodeOptions {
/**
* @description The string representing the address to get code
* @example '0xf75e354c5edc8efed9b59ee9f67a80845ade7d0c'
*/
address: string;
/**
* @description The string pre-defined block parameter, either **earliest**, **pending** or **latest**
*/
tag?: BlockExplorerTag;
}
interface GetEthStorageAtOptions {
/**
* @description The string representing the address to get code
* @example '0x6e03d9cce9d60f3e9f2597e13cd4c54c55330cfd'
*/
address: string;
/**
* @description The hex code of the position in storage
* @example '0x0'
*/
position?: string;
/**
* @description The string pre-defined block parameter, either **earliest**, **pending** or **latest**
*/
tag?: BlockExplorerTag;
}
interface GetEthEstimateGasOptions {
/**
* @description The hash of the method signature and encoded parameters
* @example '0x4e71d92d'
*/
data: string;
/**
* @description The string representing the address to interact with
* @example '0xf0160428a8552ac9bb7e050d90eeade4ddd52843'
*/
to: string;
/**
* @description The value sent in this transaction, in hex
* @example '0xff22'
*/
value?: string;
/**
* @description The gas price paid for each unit of gas, in wei
post **EIP-1559**, the **gasPrice** has to be higher than the block's **baseFeePerGas**
*/
gasPrice?: string;
/**
* @description The amount of gas provided for the transaction, in hex
* @example '0x5f5e0ff'
*/
gas?: string;
}
interface GetContractExecutionStatusOptions {
/**
* @description The string representing the transaction hash to check the execution status
* @example '0x513c1ba0bebf66436b5fed86ab668452b7805593c05073eb2d51d3a52f480a76'
*/
txhash: string;
}
/**
* Contracts options
* https://docs.etherscan.io/api-endpoints/contracts
*/
interface VerifySoliditySourceCodeOptions {
/**
* @description Code format
* - **solidity-single-file** single file;
* - **solidity-standard-json-input** JSON file ( recommended ).
*/
codeformat: BlockExplorerCodeFormat;
/**
* @description The Solidity source code
* @example `// SPDX-License-Identifier: MIT
// compiler version must be greater than or equal to 0.8.10 and less than 0.9.0
pragma solidity ^0.8.10;
contract HelloWorld {
string public greet = "Hello World!";
}`
*/
sourceCode: string;
/**
* @description Optional, include if your contract uses constructor arguments
* @example '000000000000000000000000285f5f8cd290cff6596337c4eec14e1a62235854'
*/
constructorArguments?: string;
/**
* @description The address your contract is deployed at
* @example '0x2A1D1C87d18dd13d7a1e91A42C9fFEc486EB6433'
*/
contractaddress: string;
/**
* @description The name of your contract
* @example 'HelloWorld'
*/
contractname: string;
/**
* @description Compiler version used
* @example 'v0.8.10+commit.fc410830'
*/
compilerversion: string;
/**
* @description shangai for the latest version, otherwise choose from the older versions
*/
evmversion?: string;
/**
* @description use 0 for no optimization, and 1 if optimization was used
* @example 1
*/
optimizationUsed?: 0 | 1;
/**
* @description Otimization runs
* @example 200
*/
runs?: number;
/**
* @description License type
* @example '1'
*/
licenseType?: string;
}
interface BlockExplorer {
/**
*
* @returns Get block explorer current chain id
*/
getChain: () => Chain;
/**
* Get API key string
* @returns API key
*/
getApiKey: () => string;
getUrl: () => string;
/**
* Get ether balance for a single address
* @param options
* @returns Account balance in wei
*/
getAccountBalance(options: GetAccountBalanceOptions): Promise<bigint>;
/**
* Get ether balance for multiple addresses in a single call
* @param options
* @returns Array of accounts balances
*/
getAccountsBalances(options: GetAccountsBalanceOptions): Promise<{
account: string;
balance: BigInt;
}[]>;
/**
* Get a list of 'Normal' transactions by address
* @param options
* @returns
*/
getNormalTxListByAddress(options: GetNormalTxListByAddressOptions): Promise<BlockExplorerTransaction[]>;
/**
* Get a list of 'Internal' transactions by address
* @param options
* @returns
*/
getInternalTxListByAddress(options: GetInternalTxListByAddressOptions): Promise<BlockExplorerTxInternal[]>;
/**
* Get 'internal transactions' by transaction hash
* @param options
*/
getInternalTxListByTxHash(options: GetInternalTxListByTxHashOptions): Promise<BlockExplorerTxInternalByTxHash[]>;
/**
* Get a list of 'ERC20 - token transfer events' by address
* @param options
*/
getErc20TokenTransferEventsList(options: GetErc20TokenTransferEventsListOptions): Promise<BlockExplorerErc20TokenTransferEvent[]>;
/**
* Get estimated block countdown time by BlockNo
* @param options
* @returns Countdown info object
*/
getBlockCountdownTime(options: GetBlockCountdownTimeOptions): Promise<BlockCountdownTime>;
/**
* Get block number
* @param options
* @returns Block id
*/
getBlockNumberByTimestamp(options: GetBlockNumberByTimestampOptions): Promise<number>;
/**
* Get ERC20-Token account balance for TokenContractAddress
* @param options
* @returns Account token balance (in wei mostly, but it depends on token params)
*/
getAccountTokenBalance(options: GetAccountTokenBalanceOptions): Promise<bigint>;
/**
* Get event logs by address
* @param options
* @returns Event logs array
*/
getEventLogsByAddress(options: GetEventLogsByAddressOptions): Promise<EventLog[]>;
/**
* Get event logs by topics
* @param options
* @returns Event logs array
*/
getEventLogsByTopics(options: GetEventLogsByTopicsOptions): Promise<EventLog[]>;
/**
* Get event logs by address filtered by topics
* @param options
* @returns Event logs array
*/
getEventLogsByAddressFiltered(options: GetEventLogsByAddressFilteredOptions): Promise<EventLog[]>;
/**
* Contracts chapter
* https://routescan.io/documentation/etherscan-compatibility/contracts
*/
/**
* Verify Source Code
* @param options VerifySoliditySourceCodeOptions
* @returns Verification status
*/
verifySoliditySourceCode(options: VerifySoliditySourceCodeOptions): Promise<string>;
/**
* Geth/Parity Proxy chapter
* https://routescan.io/documentation/etherscan-compatibility/geth-parity-proxy
*/
/**
* Returns the number of most recent block
* @returns Recent block number
*/
eth_blockNumber(): Promise<bigint>;
/**
* Returns information about a block by block number
* @param options
* @returns Block info
*/
eth_getBlockByNumber(options: GetEthBlockByNumberOptions): Promise<BlockExplorerBlockItem>;
/**
* Returns the number of transactions in a block
* @param options
* @returns Uncle block info
*/
eth_getUncleByBlockNumberAndIndex(options: GetEthUncleByBlockNumberAndIndexOptions): Promise<BlockExplorerBlockUncleItem>;
/**
* Returns the number of transactions in a block
* @param options
* @returns Tx count
*/
eth_getBlockTransactionCountByNumber(options: GetEthBlockTransactionCountByNumberOptions): Promise<bigint>;
/**
* Returns the information about a transaction requested by transaction hash
* @param options
* @returns Tx info
*/
eth_getTransactionByHash(options: GetEthTransactionByHashOptions): Promise<BlockExplorerTxRpc>;
/**
* Returns information about a transaction by block number and transaction index position
* @param options
* @returns Tx info
*/
eth_getTransactionByBlockNumberAndIndex(options: GetEthTransactionByBlockNumberAndIndexOptions): Promise<BlockExplorerTxRpc>;
/**
* Returns the number of transactions performed by an address
* @param options
* @returns Output tx count in hex
*/
eth_getTransactionCount(options: GetEthTransactionCountOptions): Promise<bigint>;
/**
* Submits a pre-signed transaction for broadcast to the Ethereum network
* @param options
* @returns Submitted tx hash
*/
eth_sendRawTransaction(options: GetEthSendRawTransactionOptions): Promise<string>;
/**
* Returns the receipt of a transaction by transaction hash
* @param options
* @returns Tx receipt info
*/
eth_getTransactionReceipt(options: GetEthTransactionReceiptOptions): Promise<BlockExplorerTxReceipt>;
/**
* Executes a new message call immediately without creating a transaction on the block chain
* @param options
* @returns result string
*/
eth_call(options: GetEthCallOptions): Promise<string>;
/**
* Returns code at a given address
* @param options
* @returns code string
*/
eth_getCode(options: GetEthCodeOptions): Promise<string>;
/**
* Returns the value from a storage position at a given address
* @param options
* @returns storage string
*/
eth_getStorageAt(options: GetEthStorageAtOptions): Promise<string>;
/**
* Returns the current price per gas in wei
* @returns Gas price in wei (in hex)
*/
eth_gasPrice(): Promise<string>;
/**
* Makes a call or transaction, which won't be added to the blockchain and returns the used gas
* @param options
* @returns Used gas
*/
eth_estimateGas(options: GetEthEstimateGasOptions): Promise<string>;
/**
* Transactions chapter
* https://routescan.io/documentation/etherscan-compatibility/transactions
*/
/**
* Returns the status code of a contract execution
* @param options
* @returns Tx status code
*/
getContractExecutionStatus(options: GetContractExecutionStatusOptions): Promise<BlockExplorerTxStatus>;
/**
* Check Transaction Receipt Status
* @param options
* @returns Tx receipt status code
*/
checkTransactionReceiptStatus(options: GetContractExecutionStatusOptions): Promise<BlockExplorerReceiptStatus>;
}
interface Transport {
getApiKey(): string;
getUrl(): string;
get<T>(options: any): Promise<AxiosResponse<T>>;
post<T>(options?: any, params?: any): Promise<AxiosResponse<T>>;
}
interface BlockExplorerOptions {
/**
* @description Chain id
*/
chain: Chain;
/**
* @description API key to work with blockchain explorer
*/
apiKey?: string;
/**
* @description Custom block explorer url
*/
url?: string;
/**
* Axios request config
*/
axiosOptions?: AxiosRequestConfig;
}
declare abstract class BlockExplorerCommon implements BlockExplorer {
protected chain: Chain;
protected transport: Transport;
constructor(options: BlockExplorerOptions);
abstract getBlockCountdownTime(options: GetBlockCountdownTimeOptions): Promise<BlockCountdownTime>;
abstract getBlockNumberByTimestamp(options: GetBlockNumberByTimestampOptions): Promise<number>;
abstract getAccountBalance(options: GetAccountBalanceOptions): Promise<bigint>;
abstract getAccountTokenBalance(options: GetAccountTokenBalanceOptions): Promise<bigint>;
abstract getAccountsBalances(options: GetAccountsBalanceOptions): Promise<{
account: string;
balance: BigInt;
}[]>;
abstract getNormalTxListByAddress(options: GetNormalTxListByAddressOptions): Promise<BlockExplorerTransaction[]>;
abstract getInternalTxListByAddress(options: GetInternalTxListByAddressOptions): Promise<BlockExplorerTxInternal[]>;
abstract getInternalTxListByTxHash(options: GetInternalTxListByTxHashOptions): Promise<BlockExplorerTxInternalByTxHash[]>;
abstract getErc20TokenTransferEventsList(options: GetErc20TokenTransferEventsListOptions): Promise<BlockExplorerErc20TokenTransferEvent[]>;
abstract getEventLogsByAddress(options: GetEventLogsByAddressOptions): Promise<EventLog[]>;
abstract getEventLogsByTopics(options: GetEventLogsByTopicsOptions): Promise<EventLog[]>;
abstract getEventLogsByAddressFiltered(options: GetEventLogsByAddressFilteredOptions): Promise<EventLog[]>;
abstract eth_blockNumber(): Promise<bigint>;
abstract eth_getBlockByNumber(options: GetEthBlockByNumberOptions): Promise<BlockExplorerBlockItem>;
abstract eth_getUncleByBlockNumberAndIndex(options: GetEthUncleByBlockNumberAndIndexOptions): Promise<BlockExplorerBlockUncleItem>;
abstract eth_getBlockTransactionCountByNumber(options: GetEthBlockTransactionCountByNumberOptions): Promise<bigint>;
abstract eth_getTransactionByHash(options: GetEthTransactionByHashOptions): Promise<BlockExplorerTxRpc>;
abstract eth_getTransactionByBlockNumberAndIndex(options: GetEthTransactionByBlockNumberAndIndexOptions): Promise<BlockExplorerTxRpc>;
abstract eth_getTransactionCount(options: GetEthTransactionCountOptions): Promise<bigint>;
abstract eth_sendRawTransaction(options: GetEthSendRawTransactionOptions): Promise<string>;
abstract eth_getTransactionReceipt(options: GetEthTransactionReceiptOptions): Promise<BlockExplorerTxReceipt>;
abstract eth_call(options: GetEthCallOptions): Promise<string>;
abstract eth_getCode(options: GetEthCodeOptions): Promise<string>;
abstract eth_getStorageAt(options: GetEthStorageAtOptions): Promise<string>;
abstract eth_gasPrice(): Promise<string>;
abstract eth_estimateGas(options: GetEthEstimateGasOptions): Promise<string>;
abstract getContractExecutionStatus(options: GetContractExecutionStatusOptions): Promise<BlockExplorerTxStatus>;
abstract checkTransactionReceiptStatus(options: GetContractExecutionStatusOptions): Promise<BlockExplorerReceiptStatus>;
abstract verifySoliditySourceCode(options: VerifySoliditySourceCodeOptions): Promise<string>;
protected abstract getBlockExplorerUrl(chain: Chain): string;
static build(options: BlockExplorerOptions): BlockExplorer;
getChain(): Chain;
getApiKey(): string;
getUrl(): string;
static getChainOptions(chain?: Chain): ChainItem;
}
declare class BlockExplorerEthereum extends BlockExplorerCommon {
private checkResponseStatus;
getBlockCountdownTime(options: GetBlockCountdownTimeOptions): Promise<BlockCountdownTime>;
getBlockNumberByTimestamp(options: GetBlockNumberByTimestampOptions): Promise<number>;
getAccountBalance(options: GetAccountBalanceOptions): Promise<bigint>;
getAccountsBalances(options: GetAccountsBalanceOptions): Promise<{
account: string;
balance: bigint;
}[]>;
getNormalTxListByAddress(options: GetNormalTxListByAddressOptions): Promise<BlockExplorerTransaction[]>;
getInternalTxListByAddress(options: GetNormalTxListByAddressOptions): Promise<BlockExplorerTxInternal[]>;
getInternalTxListByTxHash(options: GetInternalTxListByTxHashOptions): Promise<BlockExplorerTxInternalByTxHash[]>;
getErc20TokenTransferEventsList(options: GetErc20TokenTransferEventsListOptions): Promise<BlockExplorerErc20TokenTransferEvent[]>;
getAccountTokenBalance(options: GetAccountTokenBalanceOptions): Promise<bigint>;
getEventLogsByAddress(options: GetEventLogsByAddressOptions): Promise<EventLog[]>;
getEventLogsByTopics(options: GetEventLogsByTopicsOptions): Promise<EventLog[]>;
getEventLogsByAddressFiltered(options: GetEventLogsByAddressFilteredOptions): Promise<EventLog[]>;
protected getBlockExplorerUrl(chain?: Chain): string;
/**
* Contracts
* https://routescan.io/documentation/etherscan-compatibility/contracts
*/
verifySoliditySourceCode(options: VerifySoliditySourceCodeOptions): Promise<string>;
/**
* Geth/Parity Proxy
* https://docs.etherscan.io/api-endpoints/geth-parity-proxy
*/
eth_blockNumber(): Promise<bigint>;
eth_getBlockByNumber(options: GetEthBlockByNumberOptions): Promise<BlockExplorerBlockItem>;
eth_getUncleByBlockNumberAndIndex(options: GetEthUncleByBlockNumberAndIndexOptions): Promise<BlockExplorerBlockUncleItem>;
eth_getBlockTransactionCountByNumber(options: GetEthBlockTransactionCountByNumberOptions): Promise<bigint>;
eth_getTransactionByHash(options: GetEthTransactionByHashOptions): Promise<BlockExplorerTxRpc>;
eth_getTransactionByBlockNumberAndIndex(options: GetEthTransactionByBlockNumberAndIndexOptions): Promise<BlockExplorerTxRpc>;
eth_getTransactionCount(options: GetEthTransactionCountOptions): Promise<bigint>;
eth_sendRawTransaction(options: GetEthSendRawTransactionOptions): Promise<string>;
eth_getTransactionReceipt(options: GetEthTransactionReceiptOptions): Promise<BlockExplorerTxReceipt>;
eth_call(options: GetEthCallOptions): Promise<string>;
eth_getCode(options: GetEthCodeOptions): Promise<string>;
eth_getStorageAt(options: GetEthStorageAtOptions): Promise<string>;
eth_gasPrice(): Promise<string>;
eth_estimateGas(options: GetEthEstimateGasOptions): Promise<string>;
getContractExecutionStatus(options: GetContractExecutionStatusOptions): Promise<BlockExplorerTxStatus>;
checkTransactionReceiptStatus(options: GetContractExecutionStatusOptions): Promise<BlockExplorerReceiptStatus>;
}
declare class BlockExplorerRoutescan ex