Project description
Simple SDK that enables communication with the Covalent RESTful API bundled by microbundle.
Installation
With npm:
npm i sdk-blockchain
...or with yarn:
yarn add sdk-blockchain
API Endpoints
BalancesApi
Method | Arguments | HTTP request |
---|---|---|
getTokenBalances() |
chainId : number, address : string
|
GET/${chainId}/address/${address}/balances_v2 |
getHistoricalPortfolio() |
chainId : number, address : string
|
GET/${chainId}/address/${address}/portfolio_v2 |
Authorization
API key
Every endpoints required to be authenticated using the API key mechanism. To receive it, please go here
All you have to do is provide an API key when instantiating the SDK client:
const balance: Balances = new Balances({
apiKey: "YOUR_API_KEY",
});
Usage
balance.getTokenBalances(chainId, address).then((tokenBalances) => {
console.log({ tokenBalances });
});
balance.getHistoricalPortfolio(chainId, address).then((portfolio) => {
console.log({ portfolio });
});
for demonstration purposes these values can be used:
chainId = 1
address = "demo.eth"