1.0.5 • Published 1 year ago

@vondas/viewfinder v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

viewfinder

What?

Viewfinder is a single API for most EVM blockchain. The project extends sebs-etherscan API to more EVM blockchains. New methods are added by scanning each blockchain for their available methods. Each blockchain requires an API key that can be found for free (with restrictions) on Etherscan and Etherscan-clones (ex. Snowtrace, BSCscan, etc.). API keys are loaded using an .env file, more information below.

Requirements

  • Node.js
  • API key for supported blockchains

Installation

npm i -g viewfinder

Docs

Request

curl --location --request GET 'http://localhost:3000/util/txbyhash?blockchain=ethereum&contract=0xe6236684face5ca33c531a011071236d24460fb8&hash=0x6e471b46c6ddfc5164beb5f5ff2581acac826462b33e98471cbafc94f391765e&key=YOUR_API_KEY'

Usage

function testTxByHash(obj){
    var api = require("@vondas/viewfinder").init(obj.blockchain, obj.key);
    var output = new Promise(async(resolve, reject) => {
        try {
            response = api.proxy.eth_getTransactionByHash(obj.hash);
        } catch (ex) {
            response = null;
            reject(ex);
        }
        if (response) {
            response.then(function(txs) {
                var exportOBJ = {
                    blockchain: obj.blockchain,
                    contract: obj.contract,
                    hash: obj.hash,
                    tx: txs.result
                }
                resolve(exportOBJ);
            })
        }
    });
    return output;
}

Response

{
    "blockchain": "ethereum",
    "contract": "0xe6236684face5ca33c531a011071236d24460fb8",
    "hash": "0x6e471b46c6ddfc5164beb5f5ff2581acac826462b33e98471cbafc94f391765e",
    "tx": {
        "blockHash": "0x3c0fbfbfeb94ae16a513abbc1a668e1d1baefcbab7e53808949ddb68887f3304",
        "blockNumber": "0xd79449",
        "from": "0x3fe8c83615f7f32d11c65eb8a0a04675d8c4402b",
        "gas": "0x8774",
        "gasPrice": "0x2e5b48e700",
        "hash": "0x6e471b46c6ddfc5164beb5f5ff2581acac826462b33e98471cbafc94f391765e",
        "input": "0x095ea7b300000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
        "nonce": "0x24",
        "to": "0xe6236684face5ca33c531a011071236d24460fb8",
        "transactionIndex": "0x6d",
        "value": "0x0",
        "type": "0x0",
        "chainId": "0x1",
        "v": "0x25",
        "r": "0xb45ff9d9f38c028cd27b71e3ad5bc0466268bbdaf8565e7f448ec01cec7b2a73",
        "s": "0x24487a69f87408d11a80fd6da708e08241819695f5748f37d28a15527412648b"
    }
}

Supported Blockchains

Testnet

TestnetBlockchainEndpoint
RopstenEthereumhttps://api-ropsten.etherscan.io
KovanEthereumhttps://api-kovan.etherscan.io
RinkebyEthereumhttps://api-rinkeby.etherscan.io

Mainnet

MainnetEndpointDocs
Ethereumhttps://api.etherscan.iohttps://docs.etherscan.io/
Avalanchehttps://api.snowtrace.iohttps://snowtrace.io/apis
Binancehttps://api.bscscan.comhttps://docs.bscscan.com/
Hecohttps://api.hecoinfo.comhttps://hecoinfo.com/apis
Cronoshttps://api.cronoscan.comhttps://cronoscan.com/apis
Moonriverhttps://api-moonriver.moonscan.iohttps://moonriver.moonscan.io/apis
Moonbeamhttps://blockscout.moonbeam.networkhttps://blockscout.moonbeam.network/api-docs
Arbitrumhttps://api.arbiscan.iohttps://arbiscan.io/apis
Fantomhttps://api.ftmscan.comhttps://ftmscan.com/apis
Hooscanhttps://api.hooscan.comhttps://hooscan.com/apis
Optimismhttps://api-optimistic.etherscan.iohttps://optimistic.etherscan.io/apis

Methods & Functions by Blockchain

TypeMethodURLEthereumPolygonAvalancheBSCHecoCronosMoonriverMoonbeamArbitrumFantomHooscan
LogsgetLogsapi?module=logs&action=getLogsxxxxxxxxx--
Proxyeth_blockNumberapi?module=proxy&action=eth_blockNumberxxxxxxxx---
Proxyeth_getBlockByNumberapi?module=proxy&action=eth_getBlockByNumberxxxxxxxx---
Proxyeth_getBlockTransactionCountByNumberapi?module=proxy&action=eth_getBlockTransactionCountByNumberxxxxxxxx---
Proxyeth_getTransactionByHashapi?module=proxy&action=eth_getTransactionByHashxxxxxxxx---
Proxyeth_getTransactionByBlockNumberAndIndexapi?module=proxy&action=eth_getTransactionByBlockNumberAndIndexxxxxxxxx---
Proxyeth_getTransactionCountapi?module=proxy&action=eth_getTransactionCountxxxxxxxx---
Proxyeth_sendRawTransactionapi?module=proxy&action=eth_sendRawTransactionxxxxxxxx---
Proxyeth_getTransactionReceiptapi?module=proxy&action=eth_getTransactionReceiptxxxxxxxx---
Proxyeth_callapi?module=proxy&action=eth_callxxxxxxxx---
Proxyeth_getCodeapi?module=proxy&action=eth_getCodexxxxxxxx---
Proxyeth_getStorageAtapi?module=proxy&action=eth_getStorageAtxxxxxxxx---
Proxyeth_gasPriceapi?module=proxy&action=eth_gasPricexxxxxxxx---
Proxyeth_estimateGasapi?module=proxy&action=eth_estimateGasxxxxxxxx---
Statstokensupplyapi?module=stats&action=tokensupplyxxxxxxxx-xx
Statsethsupplyapi?module=stats&action=ethsupplyxxxxxxxx-xx
Statsethpriceapi?module=stats&action=ethpricexxxxxxxx-xx
Blockblockapi?module=block&action=gtblockrewardxxxxxxxxx--
Transactiongetstatusapi?module=transaction&action=gettxreceiptstatusxxxxxxxxx--
Contractgetabiapi?module=contract&action=getabixxxxxxxxxxx
Contractgetsourcecodeapi?module=contract&action=getsourcecodexxxxxxxxxxx
Accounttokenbalanceapi?module=account&action=tokenbalancexxxxxxxxxxx
Accountbalanceapi?module=account&action=balancexxxxxxxxxxx
Accounttxlistinternalapi?module=account&action=txlistinternalxxxxxxxxxxx
Accounttxlistapi?module=account&action=txlistxxxxxxxxxxx
Accountgetminedblocksapi?module=account&action=getminedblocksxxxxxxxxxxx
Accounttokentxapi?module=account&action=tokentxxxxxxxxxxxx
Tokentokensupplyapi?module=tokens&action=tokensupply-x---------
Tokentokenbalanceapi?module=tokens&action=tokenbalance-x---------

*subject to change