{"id":18794484,"url":"https://github.com/chainstacklabs/chainstack-covalent-sdk","last_synced_at":"2025-04-13T14:32:45.324Z","repository":{"id":173109313,"uuid":"645462766","full_name":"chainstacklabs/chainstack-covalent-sdk","owner":"chainstacklabs","description":"A JavaScript SDK designed to streamline the process of developing using the integration of Chainstack with Covalent APIs, enhancing the ease of use and efficiency","archived":false,"fork":false,"pushed_at":"2024-03-16T11:34:47.000Z","size":64,"stargazers_count":12,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-27T06:12:16.771Z","etag":null,"topics":["chainstack","covalent-api","javascript","sdk"],"latest_commit_sha":null,"homepage":"https://docs.chainstack.com/docs/work-with-chainstack-marketplace","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chainstacklabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-25T17:56:17.000Z","updated_at":"2024-10-30T14:49:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"72cbc071-a29f-440e-817b-47860ab4899e","html_url":"https://github.com/chainstacklabs/chainstack-covalent-sdk","commit_stats":null,"previous_names":["soos3d/chainstack-covalent-sdk","chainstacklabs/chainstack-covalent-sdk"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainstacklabs%2Fchainstack-covalent-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainstacklabs%2Fchainstack-covalent-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainstacklabs%2Fchainstack-covalent-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainstacklabs%2Fchainstack-covalent-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chainstacklabs","download_url":"https://codeload.github.com/chainstacklabs/chainstack-covalent-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248728225,"owners_count":21152181,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chainstack","covalent-api","javascript","sdk"],"created_at":"2024-11-07T21:29:35.252Z","updated_at":"2025-04-13T14:32:45.311Z","avatar_url":"https://github.com/chainstacklabs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg width=\"1200\" alt=\"Labs\" src=\"https://user-images.githubusercontent.com/99700157/213291931-5a822628-5b8a-4768-980d-65f324985d32.png\"\u003e\n\n\u003cp\u003e\n \u003ch3 align=\"center\"\u003eChainstack is the leading suite of services connecting developers with Web3 infrastructure\u003c/h3\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca target=\"_blank\" href=\"https://chainstack.com/build-better-with-ethereum/\"\u003e\u003cimg src=\"https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/Ethereum.svg\" /\u003e\u003c/a\u003e\u0026nbsp;  \n  \u003ca target=\"_blank\" href=\"https://chainstack.com/build-better-with-bnb-smart-chain/\"\u003e\u003cimg src=\"https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/BNB.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\n  \u003ca target=\"_blank\" href=\"https://chainstack.com/build-better-with-polygon/\"\u003e\u003cimg src=\"https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/Polygon.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\n  \u003ca target=\"_blank\" href=\"https://chainstack.com/build-better-with-avalanche/\"\u003e\u003cimg src=\"https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/Avalanche.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\n  \u003ca target=\"_blank\" href=\"https://chainstack.com/build-better-with-fantom/\"\u003e\u003cimg src=\"https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/Fantom.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  • \u003ca target=\"_blank\" href=\"https://chainstack.com/\"\u003eHomepage\u003c/a\u003e •\n  \u003ca target=\"_blank\" href=\"https://chainstack.com/protocols/\"\u003eSupported protocols\u003c/a\u003e •\n  \u003ca target=\"_blank\" href=\"https://chainstack.com/blog/\"\u003eChainstack blog\u003c/a\u003e •\n  \u003ca target=\"_blank\" href=\"https://docs.chainstack.com/quickstart/\"\u003eChainstack docs\u003c/a\u003e •\n  \u003ca target=\"_blank\" href=\"https://docs.chainstack.com/quickstart/\"\u003eBlockchain API reference\u003c/a\u003e • \u003cbr\u003e\n  • \u003ca target=\"_blank\" href=\"https://console.chainstack.com/user/account/create\"\u003eStart for free\u003c/a\u003e •\n\u003c/p\u003e\n\n# Chainstack Covalent API JavaScript SDK\n\n A JavaScript SDK designed to streamline the process of developing using the integration of Chainstack with Covalent APIs, enhancing the ease of use and efficiency.\n\n## Quickstart\n\n* Install the [Chainstack-Covalent integration](https://docs.chainstack.com/docs/work-with-chainstack-marketplace#install-an-app) from your Chainstack console. \n\n* Get a [Chainstack API key](https://docs.chainstack.com/reference/platform-api-getting-started#create-api-key).\n\n* In your project's directory, install the Chainstack SDK:\n\n```sh\nnpm i chainstack-covalent-sdk\n```\n\n* In a new file, import the Chainstack SDK and use your Chainstack API key in the constructor:\n\n```js\nconst {ChainstackApi} = require(\"chainstack-covalent-sdk\")\n\nconst CHAINSTACK_API_KEY = 'YOUR_CHAINSTACK_API_KEY'\nconst chainstack = new ChainstackApi(CHAINSTACK_API_KEY);\n```\n\n* (Optional but recommended) — The Chainstack-Covalent SDK comes with the `dotenv` package included, so you can use a `.env` file to import the Chainstack API key:\n\n    - Create a `.env` file with your Chainstack API key:\n\n    ```env\n    CHAINSTACK_API_KEY=\"YOUR_CHAINSTACK_API_KEY\"\n    ```\n\n    - Import it in your project:\n\n    ```js\n    const {ChainstackApi} = require(\"chainstack-covalent-sdk\")\n\n    const CHAINSTACK_API_KEY = process.env.CHAINSTACK_API_KEY\n    const chainstack = new ChainstackApi(CHAINSTACK_API_KEY);\n    ```\n\n## Usage\n\nThe Chainstack-Covalent SDK has many endpoints to get all sorts of data, from smart contract deployments to NFT data. Each endpoint takes an object as a parameter to configure the call to the Covalent API. \n\n### Fetch token balances\n\nThis endpoint fetches all the token balances from the specified address on the selected chain:\n\n```js\nconst {ChainstackApi} = require(\"chainstack-covalent-sdk\")\n\nconst CHAINSTACK_API_KEY = process.env.CHAINSTACK_API_KEY\nconst chainstack = new ChainstackApi(CHAINSTACK_API_KEY);\n\n// Config parameters\nconst parameters = {\n    chainName: 'eth-mainnet',\n    walletAddress: '0xae2Fc483527B8EF99EB5D9B44875F005ba1FaE13',\n    currency: 'USD',\n    nft: true,\n    noNftFetch: false,\n    noSpam: true,\n  };\n  \n  \n  chainstack.fetchTokenBalances(parameters)\n    .then(data =\u003e console.log(data))\n    .catch(error =\u003e console.error(error));\n```\n\n#### Explain the parameter object\n\nThe parameters object allows for fine tuning of your request, here is the explanation about the configuration parameters for `fetchTokenBalances`:\n\n1. **chainName** (string, required): This parameter represents the name of the blockchain network you're interested in. For example, 'eth-mainnet' for the Ethereum mainnet. Find a complete list on the [Covalent docs](https://www.covalenthq.com/docs/networks/).\n\n    ```javascript\n    const chainName = 'eth-mainnet';\n    ```\n\n2. **walletAddress** (string, required): This is the address of the wallet for which you want to fetch token balances. If you pass in an Ethereum Name Service (ENS) address or a RSK Name Service (RNS) address, it will be automatically resolved to the corresponding wallet address.\n\n    ```javascript\n    const walletAddress = '0xae2Fc483527B8EF99EB5D9B44875F005ba1FaE13';\n    ```\n\n3. **quote-currency** (string, optional): This is the currency in which you want the balances to be quoted, such as 'USD' for United States Dollars. If not provided, the balances may be returned in the native currency of the blockchain network.\n\n    ```javascript\n    const quoteCurrency = 'USD';\n    ```\n\n4. **nft** (boolean, optional): If set to `true`, Non-Fungible Tokens (NFTs) will be included in the response along with fungible tokens. If `false` or not provided, NFTs will not be included.\n\n    ```javascript\n    const nft = true;\n    ```\n\n5. **no-nft-fetch** (boolean, optional): If set to `true`, the response will only include NFTs that have been cached. This can make the response faster, as it avoids having to fetch data about NFTs from the blockchain. If `false` or not provided, all NFTs will be included, regardless of whether they are cached.\n\n    ```javascript\n    const noNftFetch = false;\n    ```\n\n6. **no-spam** (boolean, optional): If set to `true`, any tokens that are suspected to be spam will be excluded from the response. This currently supports 'eth-mainnet' and 'matic-mainnet'. If `false` or not provided, all tokens, including potential spam, will be included.\n\n    ```javascript\n    const noSpam = true;\n    ```\n    \nRemember, this function returns a promise. Handle this promise appropriately in your code, either by using `.then()` and `.catch()` methods, or by using the `await` keyword inside an async function with a try-catch block.\n\n## Work in progress\n\nThis tool and its documentation is work in progress, we will be adding a complete list of endpoints available soon.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainstacklabs%2Fchainstack-covalent-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchainstacklabs%2Fchainstack-covalent-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainstacklabs%2Fchainstack-covalent-sdk/lists"}