23 |
24 | # Chainstack Covalent API JavaScript SDK
25 |
26 | 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.
27 |
28 | ## Quickstart
29 |
30 | * Install the [Chainstack-Covalent integration](https://docs.chainstack.com/docs/work-with-chainstack-marketplace#install-an-app) from your Chainstack console.
31 |
32 | * Get a [Chainstack API key](https://docs.chainstack.com/reference/platform-api-getting-started#create-api-key).
33 |
34 | * In your project's directory, install the Chainstack SDK:
35 |
36 | ```sh
37 | npm i chainstack-covalent-sdk
38 | ```
39 |
40 | * In a new file, import the Chainstack SDK and use your Chainstack API key in the constructor:
41 |
42 | ```js
43 | const {ChainstackApi} = require("chainstack-covalent-sdk")
44 |
45 | const CHAINSTACK_API_KEY = 'YOUR_CHAINSTACK_API_KEY'
46 | const chainstack = new ChainstackApi(CHAINSTACK_API_KEY);
47 | ```
48 |
49 | * (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:
50 |
51 | - Create a `.env` file with your Chainstack API key:
52 |
53 | ```env
54 | CHAINSTACK_API_KEY="YOUR_CHAINSTACK_API_KEY"
55 | ```
56 |
57 | - Import it in your project:
58 |
59 | ```js
60 | const {ChainstackApi} = require("chainstack-covalent-sdk")
61 |
62 | const CHAINSTACK_API_KEY = process.env.CHAINSTACK_API_KEY
63 | const chainstack = new ChainstackApi(CHAINSTACK_API_KEY);
64 | ```
65 |
66 | ## Usage
67 |
68 | The 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.
69 |
70 | ### Fetch token balances
71 |
72 | This endpoint fetches all the token balances from the specified address on the selected chain:
73 |
74 | ```js
75 | const {ChainstackApi} = require("chainstack-covalent-sdk")
76 |
77 | const CHAINSTACK_API_KEY = process.env.CHAINSTACK_API_KEY
78 | const chainstack = new ChainstackApi(CHAINSTACK_API_KEY);
79 |
80 | // Config parameters
81 | const parameters = {
82 | chainName: 'eth-mainnet',
83 | walletAddress: '0xae2Fc483527B8EF99EB5D9B44875F005ba1FaE13',
84 | currency: 'USD',
85 | nft: true,
86 | noNftFetch: false,
87 | noSpam: true,
88 | };
89 |
90 |
91 | chainstack.fetchTokenBalances(parameters)
92 | .then(data => console.log(data))
93 | .catch(error => console.error(error));
94 | ```
95 |
96 | #### Explain the parameter object
97 |
98 | The parameters object allows for fine tuning of your request, here is the explanation about the configuration parameters for `fetchTokenBalances`:
99 |
100 | 1. **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/).
101 |
102 | ```javascript
103 | const chainName = 'eth-mainnet';
104 | ```
105 |
106 | 2. **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.
107 |
108 | ```javascript
109 | const walletAddress = '0xae2Fc483527B8EF99EB5D9B44875F005ba1FaE13';
110 | ```
111 |
112 | 3. **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.
113 |
114 | ```javascript
115 | const quoteCurrency = 'USD';
116 | ```
117 |
118 | 4. **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.
119 |
120 | ```javascript
121 | const nft = true;
122 | ```
123 |
124 | 5. **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.
125 |
126 | ```javascript
127 | const noNftFetch = false;
128 | ```
129 |
130 | 6. **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.
131 |
132 | ```javascript
133 | const noSpam = true;
134 | ```
135 |
136 | Remember, 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.
137 |
138 | ## Work in progress
139 |
140 | This tool and its documentation is work in progress, we will be adding a complete list of endpoints available soon.
141 |
--------------------------------------------------------------------------------
/src/utils/transactions.js:
--------------------------------------------------------------------------------
1 | const axios = require('axios');
2 | const { COVALENT_BASE_URL } = require('../config/config');
3 |
4 | module.exports = function(ChainstackApi) {
5 | ChainstackApi.prototype.fetchRecentTransactions = async function({ chainName, walletAddress, currency="USD", noLogs=false }) {
6 | try {
7 | const validatedToken = await this.validateToken();
8 |
9 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/address/${walletAddress}/transactions_v3/`);
10 | const params = { 'quote-currency': currency, 'no-logs': noLogs };
11 | url.search = new URLSearchParams(params).toString();
12 |
13 | const response = await axios.get(url, {
14 | headers: {
15 | 'Authorization': `Bearer ${validatedToken}`
16 | }
17 | });
18 |
19 | return response.data;
20 | } catch (error) {
21 | console.error('Error fetching transactions for wallet:', walletAddress, 'on chain:', chainName, 'Error:', error);
22 | throw new Error(`Failed to fetch recent transactions for wallet ${walletAddress} on chain ${chainName}: ${error.message}`);
23 | }
24 | }
25 |
26 | ChainstackApi.prototype.getPaginatedTransactionsForAddress = async function({ chainName, walletAddress, page, quoteCurrency="USD", noLogs=false }) {
27 | try {
28 | const validatedToken = await this.validateToken();
29 |
30 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/address/${walletAddress}/transactions_v3/page/${page}/`);
31 | const params = {
32 | 'quote-currency': quoteCurrency,
33 | 'no-logs': noLogs
34 | };
35 | url.search = new URLSearchParams(params).toString();
36 |
37 | const response = await axios.get(url, {
38 | headers: {
39 | 'Authorization': `Bearer ${validatedToken}`
40 | }
41 | });
42 |
43 | return response.data;
44 | } catch (error) {
45 | console.error('Error fetching paginated transactions for address:', walletAddress, 'on chain:', chainName, 'Error:', error);
46 | throw new Error(`Failed to fetch paginated transactions for address ${walletAddress} on chain ${chainName}: ${error.message}`);
47 | }
48 | }
49 |
50 | ChainstackApi.prototype.fetchContractDeploymentTransactions = async function({ chainName, walletAddress }) {
51 | try {
52 | const validatedToken = await this.validateToken();
53 |
54 | let url = `${COVALENT_BASE_URL}/${chainName}/address/${walletAddress}/transactions_v3/page/0/`;
55 |
56 | let contractDeploymentTransactions = [];
57 |
58 | while (url) {
59 | const response = await axios.get(url, {
60 | headers: {
61 | 'Authorization': `Bearer ${validatedToken}`
62 | }
63 | });
64 |
65 | const transactions = response.data.data.items;
66 | const filteredTransactions = transactions.filter(tx => tx.to_address === null);
67 | contractDeploymentTransactions = contractDeploymentTransactions.concat(filteredTransactions);
68 |
69 | url = response.data.data.links.next;
70 | }
71 |
72 | return contractDeploymentTransactions;
73 |
74 | } catch (error) {
75 | console.error('Error fetching contract deployment transactions for wallet:', walletAddress, 'on chain:', chainName, 'Error:', error);
76 | throw new Error(`Failed to fetch contract deployment transactions for wallet ${walletAddress} on chain ${chainName}: ${error.message}`);
77 | }
78 | }
79 |
80 | ChainstackApi.prototype.getTransaction = async function({ chainName, txHash, quoteCurrency="USD", noLogs=false, withDex=true, withNftSales=true, withLending=true }) {
81 | try {
82 | const validatedToken = await this.validateToken();
83 |
84 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/transaction_v2/${txHash}/`);
85 | const params = {
86 | 'quote-currency': quoteCurrency,
87 | 'no-logs': noLogs,
88 | 'with-dex': withDex,
89 | 'with-nft-sales': withNftSales,
90 | 'with-lending': withLending
91 | };
92 | url.search = new URLSearchParams(params).toString();
93 |
94 | const response = await axios.get(url, {
95 | headers: {
96 | 'Authorization': `Bearer ${validatedToken}`
97 | }
98 | });
99 |
100 | return response.data;
101 | } catch (error) {
102 | console.error('Error fetching transaction with hash:', txHash, 'on chain:', chainName, 'Error:', error);
103 | throw new Error(`Failed to fetch transaction with hash ${txHash} on chain ${chainName}: ${error.message}`);
104 | }
105 | }
106 |
107 | ChainstackApi.prototype.getTransactionSummaryForAddress = async function({ chainName, walletAddress }) {
108 | try {
109 | const validatedToken = await this.validateToken();
110 |
111 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/address/${walletAddress}/transactions_summary/`);
112 |
113 | const response = await axios.get(url, {
114 | headers: {
115 | 'Authorization': `Bearer ${validatedToken}`
116 | }
117 | });
118 |
119 | return response.data;
120 | } catch (error) {
121 | console.error('Error fetching transaction summary for address:', walletAddress, 'on chain:', chainName, 'Error:', error);
122 | throw new Error(`Failed to fetch transaction summary for address ${walletAddress} on chain ${chainName}: ${error.message}`);
123 | }
124 | }
125 |
126 | ChainstackApi.prototype.getAllTransactionsInBlock = async function({ chainName, blockHeight, quoteCurrency="USD", noLogs=false }) {
127 | try {
128 | const validatedToken = await this.validateToken();
129 |
130 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/block/${blockHeight}/transactions_v3/`);
131 | const params = {
132 | 'quote-currency': quoteCurrency,
133 | 'no-logs': noLogs
134 | };
135 | url.search = new URLSearchParams(params).toString();
136 |
137 | const response = await axios.get(url, {
138 | headers: {
139 | 'Authorization': `Bearer ${validatedToken}`
140 | }
141 | });
142 |
143 | return response.data;
144 | } catch (error) {
145 | console.error('Error fetching all transactions in block:', blockHeight, 'on chain:', chainName, 'Error:', error);
146 | throw new Error(`Failed to fetch all transactions in block ${blockHeight} on chain ${chainName}: ${error.message}`);
147 | }
148 | }
149 |
150 | ChainstackApi.prototype.getBulkTimeBucketTransactionsForAddress = async function({ chainName, walletAddress, timeBucket, quoteCurrency="USD", noLogs=false }) {
151 | try {
152 | const validatedToken = await this.validateToken();
153 |
154 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/bulk/transactions/${walletAddress}/${timeBucket}/`);
155 | const params = {
156 | 'quote-currency': quoteCurrency,
157 | 'no-logs': noLogs
158 | };
159 | url.search = new URLSearchParams(params).toString();
160 |
161 | const response = await axios.get(url, {
162 | headers: {
163 | 'Authorization': `Bearer ${validatedToken}`
164 | }
165 | });
166 |
167 | return response.data;
168 | } catch (error) {
169 | console.error('Error fetching bulk time bucket transactions for address:', walletAddress, 'on chain:', chainName, 'Error:', error);
170 | throw new Error(`Failed to fetch bulk time bucket transactions for address ${walletAddress} on chain ${chainName}: ${error.message}`);
171 | }
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/src/utils/nft.js:
--------------------------------------------------------------------------------
1 | const axios = require('axios');
2 | const { COVALENT_BASE_URL } = require('../config/config');
3 |
4 | module.exports = function(ChainstackApi) {
5 | ChainstackApi.prototype.fetchNfts = async function({ chainName, walletAddress }) {
6 | try {
7 | const validatedToken = await this.validateToken();
8 |
9 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/address/${walletAddress}/balances_nft/`);
10 | const params = { 'with-uncached': true };
11 | url.search = new URLSearchParams(params).toString();
12 |
13 | const response = await axios.get(url, {
14 | headers: {
15 | 'Authorization': `Bearer ${validatedToken}`
16 | }
17 | });
18 |
19 | return response.data;
20 | } catch (error) {
21 | console.error('Error fetching NFTs for wallet:', walletAddress, 'on chain:', chainName, 'Error:', error);
22 | throw new Error(`Failed to fetch NFTs for wallet ${walletAddress} on chain ${chainName}: ${error.message}`);
23 | }
24 | }
25 |
26 | ChainstackApi.prototype.getNftsWithMetadata = async function({ chainName, contractAddress, noMetadata, pageSize, pageNumber, traitsFilter, valuesFilter }) {
27 | try {
28 | const validatedToken = await this.validateToken();
29 |
30 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/nft/${contractAddress}/metadata/`);
31 | const params = { 'no-metadata': noMetadata, 'page-size': pageSize, 'page-number': pageNumber, 'traits-filter': traitsFilter, 'values-filter': valuesFilter };
32 | url.search = new URLSearchParams(params).toString();
33 |
34 | const response = await axios.get(url, {
35 | headers: {
36 | 'Authorization': `Bearer ${validatedToken}`
37 | }
38 | });
39 |
40 | return response.data;
41 | } catch (error) {
42 | console.error('Error fetching NFTs with metadata for contract:', contractAddress, 'on chain:', chainName, 'Error:', error);
43 | throw new Error(`Failed to fetch NFTs with metadata for contract ${contractAddress} on chain ${chainName}: ${error.message}`);
44 | }
45 | }
46 |
47 | ChainstackApi.prototype.getSingleNftWithMetadata = async function({ chainName, contractAddress, tokenId, noMetadata }) {
48 | try {
49 | const validatedToken = await this.validateToken();
50 |
51 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/nft/${contractAddress}/metadata/${tokenId}/`);
52 | const params = { 'no-metadata': noMetadata };
53 | url.search = new URLSearchParams(params).toString();
54 |
55 | const response = await axios.get(url, {
56 | headers: {
57 | 'Authorization': `Bearer ${validatedToken}`
58 | }
59 | });
60 |
61 | return response.data;
62 | } catch (error) {
63 | console.error('Error fetching single NFT with metadata for token:', tokenId, 'on contract:', contractAddress, 'on chain:', chainName, 'Error:', error);
64 | throw new Error(`Failed to fetch single NFT with metadata for token ${tokenId} on contract ${contractAddress} on chain ${chainName}: ${error.message}`);
65 | }
66 | }
67 |
68 | ChainstackApi.prototype.getSingleNftWithExternalMetadata = async function({ chainName, contractAddress, tokenId }) {
69 | try {
70 | const validatedToken = await this.validateToken();
71 |
72 | const url = `${COVALENT_BASE_URL}/${chainName}/tokens/${contractAddress}/nft_metadata/${tokenId}/`;
73 |
74 | const response = await axios.get(url, {
75 | headers: {
76 | 'Authorization': `Bearer ${validatedToken}`
77 | }
78 | });
79 |
80 | return response.data;
81 | } catch (error) {
82 | console.error('Error fetching single NFT with external metadata for token:', tokenId, 'on contract:', contractAddress, 'on chain:', chainName, 'Error:', error);
83 | throw new Error(`Failed to fetch single NFT with external metadata for token ${tokenId} on contract ${contractAddress} on chain ${chainName}: ${error.message}`);
84 | }
85 | }
86 |
87 | ChainstackApi.prototype.getNftTransactionsForContract = async function({ chainName, contractAddress, tokenId, noSpam = false }) {
88 | try {
89 | const validatedToken = await this.validateToken();
90 |
91 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/tokens/${contractAddress}/nft_transactions/${tokenId}/`);
92 |
93 | const params = { 'no-spam': noSpam };
94 | url.search = new URLSearchParams(params).toString();
95 |
96 | const response = await axios.get(url, {
97 | headers: {
98 | 'Authorization': `Bearer ${validatedToken}`
99 | }
100 | });
101 |
102 | return response.data;
103 | } catch (error) {
104 | console.error('Error fetching NFT transactions for token:', tokenId, 'on contract:', contractAddress, 'on chain:', chainName, 'Error:', error);
105 | throw new Error(`Failed to fetch NFT transactions for token ${tokenId} on contract ${contractAddress} on chain ${chainName}: ${error.message}`);
106 | }
107 | }
108 |
109 | ChainstackApi.prototype.getTraitsForCollection = async function({ chainName, collectionContract }) {
110 | try {
111 | const validatedToken = await this.validateToken();
112 |
113 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/nft/${collectionContract}/traits/`);
114 |
115 | const response = await axios.get(url, {
116 | headers: {
117 | 'Authorization': `Bearer ${validatedToken}`
118 | }
119 | });
120 |
121 | return response.data;
122 | } catch (error) {
123 | console.error('Error fetching traits for collection:', collectionContract, 'on chain:', chainName, 'Error:', error);
124 | throw new Error(`Failed to fetch traits for collection ${collectionContract} on chain ${chainName}: ${error.message}`);
125 | }
126 | }
127 |
128 | ChainstackApi.prototype.getTraitSummaryForCollection = async function({ chainName, collectionContract }) {
129 | try {
130 | const validatedToken = await this.validateToken();
131 |
132 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/nft/${collectionContract}/traits_summary/`);
133 |
134 | const response = await axios.get(url, {
135 | headers: {
136 | 'Authorization': `Bearer ${validatedToken}`
137 | }
138 | });
139 |
140 | return response.data;
141 | } catch (error) {
142 | console.error('Error fetching trait summary for collection:', collectionContract, 'on chain:', chainName, 'Error:', error);
143 | throw new Error(`Failed to fetch trait summary for collection ${collectionContract} on chain ${chainName}: ${error.message}`);
144 | }
145 | }
146 |
147 | ChainstackApi.prototype.getAttributesForCollectionTrait = async function({ chainName, collectionContract, trait }) {
148 | try {
149 | const validatedToken = await this.validateToken();
150 |
151 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/nft/${collectionContract}/traits/${trait}/attributes/`);
152 |
153 | const response = await axios.get(url, {
154 | headers: {
155 | 'Authorization': `Bearer ${validatedToken}`
156 | }
157 | });
158 |
159 | return response.data;
160 | } catch (error) {
161 | console.error('Error fetching attributes for collection trait:', trait, 'on chain:', chainName, 'Error:', error);
162 | throw new Error(`Failed to fetch attributes for collection trait ${trait} on chain ${chainName}: ${error.message}`);
163 | }
164 | }
165 |
166 | ChainstackApi.prototype.getChainCollections = async function({ chainName, pageSize, pageNumber, noSpam = false }) {
167 | try {
168 | const validatedToken = await this.validateToken();
169 |
170 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/nft/collections/`);
171 | const params = {
172 | 'page-size': pageSize,
173 | 'page-number': pageNumber,
174 | 'no-spam': noSpam
175 | };
176 | url.search = new URLSearchParams(params).toString();
177 |
178 | const response = await axios.get(url, {
179 | headers: {
180 | 'Authorization': `Bearer ${validatedToken}`
181 | }
182 | });
183 |
184 | return response.data;
185 | } catch (error) {
186 | console.error('Error fetching chain collections on chain:', chainName, 'Error:', error);
187 | throw new Error(`Failed to fetch chain collections on chain ${chainName}: ${error.message}`);
188 | }
189 | }
190 |
191 | ChainstackApi.prototype.checkOwnershipInNftCollection = async function({ chainName, walletAddress, collectionContract }) {
192 | try {
193 | const validatedToken = await this.validateToken();
194 |
195 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/address/${walletAddress}/collection/${collectionContract}/`);
196 |
197 | const response = await axios.get(url, {
198 | headers: {
199 | 'Authorization': `Bearer ${validatedToken}`
200 | }
201 | });
202 |
203 | return response.data;
204 | } catch (error) {
205 | console.error('Error checking ownership in NFT collection:', collectionContract, 'Error:', error);
206 | throw new Error(`Failed to check ownership in NFT collection ${collectionContract}: ${error.message}`);
207 | }
208 | }
209 |
210 | ChainstackApi.prototype.checkOwnershipInNftCollectionForSpecificToken = async function({ chainName, walletAddress, collectionContract, tokenId }) {
211 | try {
212 | const validatedToken = await this.validateToken();
213 |
214 | const url = new URL(`${COVALENT_BASE_URL}/${chainName}/address/${walletAddress}/collection/${collectionContract}/token/${tokenId}/`);
215 |
216 | const response = await axios.get(url, {
217 | headers: {
218 | 'Authorization': `Bearer ${validatedToken}`
219 | }
220 | });
221 |
222 | return response.data;
223 | } catch (error) {
224 | console.error('Error checking ownership in NFT collection for specific token:', tokenId, 'Error:', error);
225 | throw new Error(`Failed to check ownership in NFT collection for specific token ${tokenId}: ${error.message}`);
226 | }
227 | }
228 | }
229 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------