ankr-network / ankr.js Goto Github PK
View Code? Open in Web Editor NEWJavascript library for interacting with Ankr APIs
Home Page: https://www.npmjs.com/package/@ankr.com/ankr.js
License: MIT License
Javascript library for interacting with Ankr APIs
Home Page: https://www.npmjs.com/package/@ankr.com/ankr.js
License: MIT License
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
I am using Supabase functions (powered by Deno). I am importing @ankr.com/ankr.js using an import map and skypack.dev as follows
{
"imports": {
"server": "https://deno.land/[email protected]/http/server.ts",
"lodash": "https://cdn.skypack.dev/lodash",
"ethers": "https://cdn.skypack.dev/[email protected]",
"http_status": "https://deno.land/std/http/http_status.ts",
"@ankr.com/ankr.js": "https://cdn.skypack.dev/@ankr.com/ankr.js",
}
}
I am making the following call:
import { AnkrProvider } from "@ankr.com/ankr.js"
const blockchain = [
'eth',
'bsc',
'polygon',
'avalanche'
]
const provider = new AnkrProvider()
export async function balances(walletAddress: string) {
return await provider.getAccountBalance({
blockchain,
walletAddress
})
}
Which results in the following error:
TypeError: adapter is not a function
at dispatchRequest2 (https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=imports/optimized/axios.js:850:10)
at Axios.request (https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=imports/optimized/axios.js:1057:15)
at Axios.<computed> [as post] (https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=imports/optimized/axios.js:1081:17)
at Function.wrap [as post] (https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=imports/optimized/axios.js:7:15)
at AnkrProvider2.<anonymous> (https://cdn.skypack.dev/-/@ankr.com/[email protected]/dist=es2019,mode=imports/optimized/@ankr.com/ankrjs.js:131:48)
at Generator.next (<anonymous>)
at https://cdn.skypack.dev/-/@ankr.com/[email protected]/dist=es2019,mode=imports/optimized/@ankr.com/ankrjs.js:43:69
at new Promise (<anonymous>)
at __awaiter (https://cdn.skypack.dev/-/@ankr.com/[email protected]/dist=es2019,mode=imports/optimized/@ankr.com/ankrjs.js:25:12)
at AnkrProvider2.send (https://cdn.skypack.dev/-/@ankr.com/[email protected]/dist=es2019,mode=imports/optimized/@ankr.com/ankrjs.js:129:14)
It looks to me like this is an issue with the config of the Axios library.
So far, I have tried to add the regenerator-runtime
but it hasn't helped.
export interface GetTransactionsByAddressRequest {
blockchain?: Blockchain;
walletAddress: string;
timestamp?: number;
orderAsc?: boolean;
pageToken?: string;
pageSize?: number;
}
At the time of writing this, no environment supports ES6 modules natively. When using them in Node.js you need to use something like Babel to convert the modules to CommonJS. But how exactly does that happen?
Many people consider module.exports = ... to be equivalent to export default ... and exports.foo ... to be equivalent to export const foo = .... That's not quite true though, or at least not how Babel does it.
ES6 default exports are actually also named exports, except that default is a "reserved" name and there is special syntax support for it
https://stackoverflow.com/questions/40294870/module-exports-vs-export-default-in-node-js-and-es6
I tried to run a shell script in the docs https://www.ankr.com/rpc/advanced-api
curl --location --request POST 'https://rpc.ankr.com/multichain' \ --header 'Content-Type: application/json' \ --data-raw '{ "id": 1, "jsonrpc": "2.0", "method": "ankr_getAccountBalance", "params": { "blockchain": [ "bsc", "eth", "polygon", "avalanche" ], "walletAddress": "0xfa9019df60d3c710d7d583b2d69e18d412257617" } }'
But got error below
{"jsonrpc":"2.0","error":{"code":0,"message":"not authorized"},"id":null}
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:
await provider.getNFTsByOwner({
blockchain: "bsc",
walletAddress: "0xe1b852bbec7ab161d554765667814cb3ca0ad142",
pageSize: 2,
pageToken: "",
filter: [
{
"0xC3c3B849ED5164Fb626c4a4F78e0675907B2C94E": []
}
]
});
Not working example:
await provider.getNFTsByOwner({
blockchain: "bsc",
walletAddress: "0xe1b852bbec7ab161d554765667814cb3ca0ad142",
pageSize: 2,
pageToken: "",
filter: [
{
"0x21Dc6714c4a3fccD67f53453b46e1c892A54C8E7": []
}
]
});
I want to confirm that I updated ankr.js version to the latest version (v0.3.1) and read the latest docs here but got error getTokenPriceHistory is not a function
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
Hi, thanks for this sdk. Just wanted to find out which api key this requires and the limits for the multichain rpc per ip and/or key
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"
}
}
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
Current result: 5 times got this empty result / total 10 tried requests
Expected
With the same request above the method should return data instead of empty result in the randomly time
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
Expected result
ETH token returned in the result
Current result
Missed ETH token in the result
any plans to added typescript support?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.