Compact library for interacting with Ankr Scan Multichain API.

Overview

ankrscan.js

Compact SDK for interacting with Ankr Scan MultiChain JSON-RPC API.

SDK supports following MultiChain methods:

  • getLogs - logs matching the filter.
  • getBlocksRange - blocks within specified range.
  • getAccountBalance - coin and token balances of the wallet.
  • getNFTsByOwner - NFT collectibles of the wallet.

MultiChain support:

  • ETH: "eth"
  • BSC: "bsc"
  • Polygon: "polygon"
  • Fantom: "fantom"
  • Arbitrum: "arbitrum"
  • Avalanche: "avalanche"

Installation

npm install ankrscan.js

or

yarn add ankrscan.js

Import

node.js require

const { AnkrscanProvider } = require("ankrscan.js");

ES6 or TypeScript

import AnkrscanProvider from "ankrscan.js";

Usage example

import AnkrscanProvider from "ankrscan.js";

// Create a provider
const provider = new AnkrscanProvider("YOUR-API-KEY")

// Get logs
const filterLogs = async () => {
    return await provider.getLogs({
        blockchain: "eth",
        fromBlock: 1181739,
        toBlock: 1181739,
        topics: [[], ["0x000000000000000000000000feb92d30bf01ff9a1901666c5573532bfa07eeec"]],
        address: "0x3589d05a1ec4af9f65b0e5554e645707775ee43c"
    })
}

// Blocks range
const getBlocks = async () => {
    return await provider.getBlocksRange({
        blockchain: "bsc",
        fromBlock: 100,
        toBlock: 200
    })
}

// Account balances
const getBalances = async () => {
    return await provider.getAccountBalance({
        blockchain: "eth",
        walletAddress: "0xfa9019df60d3c710d7d583b2d69e18d412257617"
    })
}

// Get NFTs
const getNFTs = async () => {
    return await provider.getNFTsByOwner({
        blockchain: "eth",
        walletAddress: "0x0E11A192d574b342C51be9e306694C41547185DD",
        filter: [
            {"0x700b4b9f39bb1faf5d0d16a20488f2733550bff4": []},
            {"0xd8682bfa6918b0174f287b888e765b9a1b4dc9c3": ["8937"]}
        ]
    })
}
Comments
  • getNFTsByOwner method doesn't work for some contracts

    getNFTsByOwner method doesn't work for some contracts

    While testing the SDK, I noticed that the getNFTsByOwner method doesn't work for certain NFTs, I will guess it's because the NFT isn't indexed yet? Not sure!

    Working example:

    Bscscan link

    await provider.getNFTsByOwner({
      blockchain: "bsc",
      walletAddress: "0xe1b852bbec7ab161d554765667814cb3ca0ad142",
      pageSize: 2,
      pageToken: "",
      filter: [
          {
              "0xC3c3B849ED5164Fb626c4a4F78e0675907B2C94E": []
          }
      ]
    });
    

    Not working example:

    Bscscan link

    await provider.getNFTsByOwner({
      blockchain: "bsc",
      walletAddress: "0xe1b852bbec7ab161d554765667814cb3ca0ad142",
      pageSize: 2,
      pageToken: "",
      filter: [
          {
              "0x21Dc6714c4a3fccD67f53453b46e1c892A54C8E7": []
          }
      ]
    });
    
    opened by artpumpkin 6
  • ankr_getAccountBalance is not stable

    ankr_getAccountBalance is not stable

    My problem I used "@ankr.com/[email protected]" package for get account balance with my premium plan, tried to call ankr_getAccountBalance 10 times, 5 times I got empty returned result

    This is my request params Screenshot 2022-11-07 at 11 23 40

    Current result: 5 times got this empty result / total 10 tried requests Screenshot 2022-11-07 at 11 24 33

    Expected With the same request above the method should return data instead of empty result in the randomly time image

    opened by aminhdev 3
  • chore: 🤖 add types for `blockchain` fields

    chore: 🤖 add types for `blockchain` fields

    This PR adds a new type Blockchain and assigns it to the blockchain fields in all API responses for better autocomplete support.

    (PS: I work at Ankr too xD, DevRel)

    opened by Dhaiwat10 3
  • tokenPrice for ETH showing 0 when get account balance

    tokenPrice for ETH showing 0 when get account balance

    I tried to use this example from the docs but got tokenPrice = 0 for ETH curl --location --request POST 'https://rpc.ankr.com/multichain' \ --header 'Content-Type: application/json' \ --data-raw '{ "jsonrpc": "2.0", "method": "ankr_getAccountBalance", "params": { "blockchain": "eth", "walletAddress": "0xfa9019df60d3c710d7d583b2d69e18d412257617" }, "id": 1 }'

    Current result for ETH tokenPrice

    [
    ...
    {
          "blockchain": "eth",
          "tokenName": "Ethereum",
          "tokenSymbol": "ETH",
          "tokenDecimals": 18,
          "tokenType": "NATIVE",
          "holderAddress": "0xfa9019df60d3c710d7d583b2d69e18d412257617",
          "balance": "4.54492462147",
          "balanceRawInteger": "4544924621470000000",
          "balanceUsd": "0",
          "tokenPrice": "0",
          "thumbnail": "https://www.ankr.com/protocol/static/media/eth.3ee8ddd4.svg"
        }
    ...
    ]
    
    

    Expected result for ETH tokenPrice The current ETH price

    opened by aminhdev 1
  • Readme improvement suggestions

    Readme improvement suggestions

    Hi @romanankr! Here is the PR with some suggestions for the readme. I tried to make the language we use in our readme more dev-friendly and tried to make it easier for people to get started with our package.

    opened by Dhaiwat10 0
  • The information retrieved through getNFTsByOwner is different

    The information retrieved through getNFTsByOwner is different

    The metadata information obtained through getNFTsByOwner does not match what is in opensea.

    The json below is the NFT information obtained through ankr.

    ANKR owner: 0xc8B1735929eDa28822721fd9Bdbb1D3de2b3eab2

    {

                "contract": {
    
                    "address": "0x1f47ea34d27ecf77bf04a702fbd9e7b7a4b38024",
    
                    "name": "Merge Machines",
    
                    "symbol": "MERGE",
    
                    "totalSupply": "",
    
                    "tokenType": "ERC721"
    
                },
    
                "tokenId": "1128",
    
                "tokenType": "ERC721",
    
                "title": "Kinetic #1128",
    
                "description": "",
    
                "tokenUri": {
    
                    "raw": "https://mergemachines-data.uc.r.appspot.com/metadata/1128",
    
                    "gateway": "https://mergemachines-data.uc.r.appspot.com/metadata/1128"
    
                },
    
                "media": {
    
                    "raw": "https://storage.googleapis.com/merge-machines-images/gif/1128.gif",
    
                    "gatewal": "https://storage.googleapis.com/merge-machines-images/gif/1128.gif"
    
                },
    
                "balance": 1
    
            }
    

    https://opensea.io/assets/ethereum/0x1f47ea34d27ecf77bf04a702fbd9e7b7a4b38024/1128

    opened by blockdev337 1
  • Errors when trying to get a token price history from polygon

    Errors when trying to get a token price history from polygon

    I'm trying to read a price history from polygon and I just get an error, I doesn't matter with contract address I pass. Tried already by sdk and api directly. Tried with the other blockchains and is working, expect polygon.

    Example:

        "jsonrpc": "2.0",
        "method": "ankr_getTokenPriceHistory",
        "params": {  
            "blockchain": "polygon",
            "contractAddress": "0x0000000000000000000000000000000000001010",
            "toTimestamp": 1667195581,
            "interval": 6000,
            "limit": 8
        },
        "id": 1
    }
    
    Result:
    {
        "jsonrpc": "2.0",
        "id": 137,
        "error": {
            "code": -32005,
            "message": "Not found: no prices for token=0x0000000000000000000000000000000000001010"
        }
    }
    
    opened by marco-quintella 1
  • Missed token returned by ankr_getAccountBalance method

    Missed token returned by ankr_getAccountBalance method

    Get account balance by running this

    curl --location --request POST 'https://rpc.ankr.com/multichain' \
    --header 'Content-Type: application/json' \
    --header 'X-API-KEY: $$$$$$$$$$$$$$$$$$$$$$' \
    --data-raw '{
        "jsonrpc": "2.0",
        "method": "ankr_getAccountBalance",
        "params": {  
            "walletAddress": "0xdaf835f11537fca6db91e91c266d153200f46d52",
            "pageSize": 10000
        },
        "id": 1
    }'
    

    This is list tokens of 0xdaf835f11537fca6db91e91c266d153200f46d52 image

    Expected result ETH token returned in the result

    Current result Missed ETH token in the result

    opened by aminhdev 3
Releases(v0.1.12)
Owner
Ankr
Web3 Infrastructure
Ankr
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
js-sdk for multichain storage service

js-mcs-sdk Table of Contents Introduction Prerequisites MCS API Usage Installation Getting Started Documentation Contributing Introduction A client li

FilSwan 3 Aug 5, 2022
🚀👩‍🚀This repo contains all the files to follow along and implement a MultiChain NFT MarketPlace! Be sure to watch my Youtube tutorials so you can learn and follow along!

Multi-Chain NFT Marketplace ?? ??‍?? This repo contains all the files to follow along and implement a MultiChain NFT MarketPlace! Be sure to watch my

Net2Dev 30 Jan 5, 2023
A compact JavaScript animation library with a GUI timeline for fast editing.

Timeline.js A compact JavaScript animation library with a GUI timeline for fast editing. Check it out in this example: http://vorg.github.io/timeline.

Marcin Ignac 516 Nov 26, 2022
A pure JavaScript Web Page to retrieve real-time OTP through a web page and generate/scan QR codes.

2FA-Solver A pure JavaScript Web Page to retrieve real-time OTP through a web page and generate/scan QR codes. It can be used as an offline web page b

Yuthan K 8 Dec 7, 2022
LunaSec - Open Source Security Software built by Security Engineers. Scan your dependencies for Log4Shell, or add Data Tokenization to prevent data leaks. Try our live Tokenizer demo: https://app.lunasec.dev

Our Software We're a team of Security Engineers on a mission to make awesome Open Source Application Security tooling. It all lives in this repo. Here

LunaSec 1.2k Jan 7, 2023
With monitors getting wider and websites more compact, maximizing the browser is a waste of space.

With monitors getting wider and websites more compact, maximizing the browser is a waste of space. Widefox utilizes all available vertical real estate while adding extra features to your browsing experience!

null 46 Dec 18, 2022
A flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh

three-bvh-csg An experimental, in progress, flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh. More than 100 time

Garrett Johnson 208 Jan 5, 2023
EasyPen is a GUI program which helps pentesters do target discovery, vulnerability scan and exploitation

EasyPen Alpha 1.0.5 Do not use EasyPen for illegal purposes, this tool is for research only 查看中文 EasyPen is a GUI program which helps pentesters do ta

null 486 Dec 25, 2022
JavaScript API based capstone project using TVmaze API for displaying and interacting with items from the data base.

Yuriy Chamkoriyski & Bonke Gcobo Javascript capstone project API-based webapp from Module 2 at Microverse Wireframe requirements The Home Page low fid

Yuriy Chamkoriyski 5 May 30, 2022
📡Usagi-http-interaction: A library for interacting with Http Interaction API

?? - A library for interacting with Http Interaction API (API for receiving interactions.)

Rabbit House Corp 3 Oct 24, 2022
Type safe library for interacting with Mindbody's Public API (v6) and Webhooks

Mindbody API Type safe library for interacting with Mindbody's Public API (v6) and Webhooks ⚠️ Read before installing This library is typed according

SplitPass 4 Dec 9, 2022
Framework for interacting with instagrams private api in a usable manner (forked from andre's work and improved and fixed)

node-ig-framework Framework for interacting with instagrams private api in a usable manner (forked from andre's work and improved and fixed) Installat

nine ecksen 3 Dec 31, 2022
starter kit for interacting with zora api, protocol, and creator toolkit

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

tranqui.eth 40 Oct 20, 2022
Library for interacting with RMM protocol through ethers.js.

?? rmm-ethers Easily connect and transact with RMM protocol. ?? Features ?? Deploy RMM protocol ⚡️ Easily connect to an RMM deployment ?? Create RMM p

Primitive 14 Nov 13, 2022
A Deno library for interacting with the mouse 🖱️ keyboard ⌨️ and screen 💻

A Deno library for interacting with the mouse ??️ keyboard ⌨️ and screen ?? . Litebot provides a simple API for creating kbm events, macros, & working with displays. Litebot leverages Deno's FFI to allow speedy low level control in C & C++ while having a typescript API exposed to the user.

Tyler Laceby 10 Aug 30, 2022
JavaScript library for parsing Dirtywave M8 files, complete with a CLI for interacting with M8 files.

m8-js This repository contains a JavaScript library for parsing Dirtywave M8 files, as well as a CLI for interacting with M8 files. The hopes are not

Jeremy Whitlock 20 Dec 17, 2022