From 06cfdd6dcc877c6390ed7cdb612317fff4e191e0 Mon Sep 17 00:00:00 2001 From: Trevor Clarke Date: Tue, 14 Apr 2020 13:09:01 -0700 Subject: [PATCH 1/3] adding better intro documentation --- docs/api.md | 132 ++++++++++++++++++++++---------------------- docs/quick-start.md | 103 ++++++++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+), 66 deletions(-) diff --git a/docs/api.md b/docs/api.md index f2e6888..db316ed 100644 --- a/docs/api.md +++ b/docs/api.md @@ -547,46 +547,6 @@ const metrics = await web3data.address.getMetrics('0x3f5ce5fbfe3e9af3971dd833d26 -### src/bch.js - - -#### new Bch() *private method* - -Class for all Bitcoin Cash based methods. - - - - - - -##### Returns - - -- `Void` - - - - -### src/bsv.js - - -#### new Bsv() *private method* - -Class for all Bitcoin SV based methods. - - - - - - -##### Returns - - -- `Void` - - - - ### src/block.js @@ -924,6 +884,26 @@ Retrieves the blocks metrics & statistics. If no DateRange is specified, it will +### src/bch.js + + +#### new Bch() *private method* + +Class for all Bitcoin Cash based methods. + + + + + + +##### Returns + + +- `Void` + + + + ### src/blockchain.js @@ -988,6 +968,26 @@ const metrics = await web3data.blockchain.getMetrics() +### src/bsv.js + + +#### new Bsv() *private method* + +Class for all Bitcoin SV based methods. + + + + + + +##### Returns + + +- `Void` + + + + ### src/btc.js @@ -1220,6 +1220,26 @@ Class for all Ethereum based methods. +##### Returns + + +- `Void` + + + + +### src/ltc.js + + +#### new Ltc() *private method* + +Class for all Litecoin based methods. + + + + + + ##### Returns @@ -1644,26 +1664,6 @@ const batTokenAddress = web3data.market.getAssetAddresses('bat') const assetAddr -### src/ltc.js - - -#### new Ltc() *private method* - -Class for all Litecoin based methods. - - - - - - -##### Returns - - -- `Void` - - - - ### src/signature.js @@ -3145,12 +3145,12 @@ Sends unsubscription message to the websocket connection. -### src/zec.js +### src/xlm.js -#### new Zec() *private method* +#### new Xlm() *private method* -Class for all ZCash based methods. +Class for all Stellar based methods. @@ -3165,12 +3165,12 @@ Class for all ZCash based methods. -### src/xlm.js +### src/zec.js -#### new Xlm() *private method* +#### new Zec() *private method* -Class for all Stellar based methods. +Class for all ZCash based methods. diff --git a/docs/quick-start.md b/docs/quick-start.md index 4e0744c..24dc818 100644 --- a/docs/quick-start.md +++ b/docs/quick-start.md @@ -1,5 +1,12 @@ ![Web3data.js Javascript API](./assets/web3data-js-logo-banner.png) +[![Build Status](https://travis-ci.com/web3data/web3data-js.svg?branch=master)](https://travis-ci.com/web3data/web3data-js) +[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) +[![Try web3data-js on RunKit](https://badge.runkitcdn.com/web3data-js.svg)](https://npm.runkit.com/web3data-js) + +# Web3data.js Javascript API +Wrapper for [Amberdata.io](http://amberdata.io)'s [REST API](http://docs.amberdata.io/reference) + ## Installation Note that you must have node (and npm) installed. @@ -13,6 +20,17 @@ Using CDN: ``` +## The API Key +Visit [Amberdata.io](https://amberdata.io/pricing) and select the developer plan to get started! + +Once you've got your key, place it in a file named `.env` — see [env.example](./env.example) for reference. + +Then in you code you can use it like so: + +```javascript +const web3Data = new Web3Data(process.env.API_KEY) +``` + ## Configuration Web3data configuration is simple and only requires an API Key upon instantiation. ```javascript @@ -30,11 +48,83 @@ requests via web3data.js. You can find the full [list of blockchain IDs](https://docs.amberdata.io/reference#blockchain-ids) in our docs. + +## Simple Usage Example + +For more examples, [click here to head over to view more quick examples](/examples). For a full spectrum of guides, tutorials & sample code, go to [our Amberdata Documentation](https://amberdata.io/docs). For filters & optional parameters, please [refer to the API documentation](https://docs.amberdata.io). + +#### Within Node +```js +import Web3Data from 'web3data-js' + +const w3d = new Web3Data('') + +;( async () => { + const contract = await w3d.contract.getDetails("0x06012c8cf97bead5deae237070f9587f8e7a266d") + console.log(contract) // { ... } +})() +``` + +#### Websockets Events +```js +import Web3Data from 'web3data-js' + +const w3d = new Web3Data('') + +w3d.connect(status => { + console.log('status ->', status.type) +}) +w3d.on({eventName: 'block'}, data => { + console.log(data) +}) +``` + ## Blockchains/Networks It's possible to the namespace convention to specify which blockchain to use when making requests. This makes it easier to switch between blockchains as Web3data will automatically set the correct headers under the hood. +### Supported Blockchain Namespaces + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameNamespace
defaultweb3data.* (Ethereum)
Bitcoinweb3data.btc
Ethereumweb3data.eth
Litecoinweb3data.ltc
Bitcoin Cashweb3data.bch
Bitcoin SVweb3data.bsv
Stellarweb3data.xlm
Zcashweb3data.zec
+ ### Ethereum **Namespace**: `.eth` @@ -74,29 +164,42 @@ web3data.eth.address.getBalance('0x734Ac651Dd95a339c633cdEd410228515F97fAfF') getTransactions getTransactions + getPendingTransactions getTransactionFromBlock + getBalance getMetrics + getLatestBalance + + getHistoricalBalance + + getMultipleBalances + + getBalancesBatch + + getMetrics + + From 41747241add40a1dd88d3f7c16e8571e20eb1cd9 Mon Sep 17 00:00:00 2001 From: Trevor Clarke Date: Tue, 14 Apr 2020 13:10:32 -0700 Subject: [PATCH 2/3] minor verb change --- docs/_sidebar.md | 4 +- docs/api.md | 184 +++++++++++++++++++++++------------------------ 2 files changed, 94 insertions(+), 94 deletions(-) diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 54a8454..e6e8fd2 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -1,8 +1,8 @@ - [Getting Started](quick-start.md) - [Examples](examples.md) - Core Methods - - [web3data](api.md?id=web3datafactoryconstructorapikey-options-blockchainid-) - - [webSockets](api.md?id=new-websocketclient) + - [Web3Data](api.md?id=web3datafactoryconstructorapikey-options-blockchainid-) + - [Websockets](api.md?id=new-websocketclient) - [RPC](api.md?id=web3datafactoryrpcmethod-params) - Market Data Methods - [market.getFeatures](api.md?id=getfeaturesfeatures-filteroptions) diff --git a/docs/api.md b/docs/api.md index db316ed..593d88b 100644 --- a/docs/api.md +++ b/docs/api.md @@ -547,6 +547,26 @@ const metrics = await web3data.address.getMetrics('0x3f5ce5fbfe3e9af3971dd833d26 +### src/bch.js + + +#### new Bch() *private method* + +Class for all Bitcoin Cash based methods. + + + + + + +##### Returns + + +- `Void` + + + + ### src/block.js @@ -884,12 +904,12 @@ Retrieves the blocks metrics & statistics. If no DateRange is specified, it will -### src/bch.js +### src/btc.js -#### new Bch() *private method* +#### new Btc() *private method* -Class for all Bitcoin Cash based methods. +Class for all Bitcoin based methods. @@ -980,26 +1000,6 @@ Class for all Bitcoin SV based methods. -##### Returns - - -- `Void` - - - - -### src/btc.js - - -#### new Btc() *private method* - -Class for all Bitcoin based methods. - - - - - - ##### Returns @@ -1208,12 +1208,12 @@ const code = await web3data.contract.getCode('0x06012c8cf97bead5deae237070f9587f -### src/eth.js +### src/ltc.js -#### new Eth() *private method* +#### new Ltc() *private method* -Class for all Ethereum based methods. +Class for all Litecoin based methods. @@ -1228,18 +1228,48 @@ Class for all Ethereum based methods. -### src/ltc.js +### src/signature.js -#### new Ltc() *private method* +#### new Signature() + +Contains methods pertaining to the `/signatures` endpoint of Amberdata's API. + + + + + + +##### Returns + + +- `Void` -Class for all Litecoin based methods. +#### Signature.constructor(web3data) + +Creates an instance of Signature. + + + + +##### Parameters + +| Name | Type | Description | | +| ---- | ---- | ----------- | -------- | +| web3data | `object` | - The web3data instance. |   | +##### Examples + +```javascript +new Signature(new Web3Data('API_KEY')) +``` + + ##### Returns @@ -1247,6 +1277,36 @@ Class for all Litecoin based methods. +#### Signature.getSignature(hash) + +Retrieves detailed information about the specified signature hash. + + + + +##### Parameters + +| Name | Type | Description | | +| ---- | ---- | ----------- | -------- | +| hash | `string` | - The (keccak 256) of the signature. |   | + + + + +##### Examples + +```javascript +const signatureDetails = await web3data.signature.getSignature('0xe2f0a05a') +``` + + +##### Returns + + +- `Promise.<Array>` Information pertaining to the specified signature hash. + + + ### src/market.js @@ -1664,47 +1724,17 @@ const batTokenAddress = web3data.market.getAssetAddresses('bat') const assetAddr -### src/signature.js - - -#### new Signature() - -Contains methods pertaining to the `/signatures` endpoint of Amberdata's API. - - - - - - -##### Returns - - -- `Void` - - - -#### Signature.constructor(web3data) - -Creates an instance of Signature. - +### src/eth.js +#### new Eth() *private method* -##### Parameters +Class for all Ethereum based methods. -| Name | Type | Description | | -| ---- | ---- | ----------- | -------- | -| web3data | `object` | - The web3data instance. |   | -##### Examples - -```javascript -new Signature(new Web3Data('API_KEY')) -``` - ##### Returns @@ -1713,36 +1743,6 @@ new Signature(new Web3Data('API_KEY')) -#### Signature.getSignature(hash) - -Retrieves detailed information about the specified signature hash. - - - - -##### Parameters - -| Name | Type | Description | | -| ---- | ---- | ----------- | -------- | -| hash | `string` | - The (keccak 256) of the signature. |   | - - - - -##### Examples - -```javascript -const signatureDetails = await web3data.signature.getSignature('0xe2f0a05a') -``` - - -##### Returns - - -- `Promise.<Array>` Information pertaining to the specified signature hash. - - - ### src/token.js From 0079e8b70653d894f4d1ac244532d089c3a9934c Mon Sep 17 00:00:00 2001 From: Trevor Clarke Date: Tue, 14 Apr 2020 13:21:38 -0700 Subject: [PATCH 3/3] added full blockchain support reference --- docs/api.md | 438 ++++++++++++++++++++++---------------------- docs/quick-start.md | 399 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 617 insertions(+), 220 deletions(-) diff --git a/docs/api.md b/docs/api.md index 593d88b..69eb8be 100644 --- a/docs/api.md +++ b/docs/api.md @@ -559,6 +559,26 @@ Class for all Bitcoin Cash based methods. +##### Returns + + +- `Void` + + + + +### src/bsv.js + + +#### new Bsv() *private method* + +Class for all Bitcoin SV based methods. + + + + + + ##### Returns @@ -904,26 +924,6 @@ Retrieves the blocks metrics & statistics. If no DateRange is specified, it will -### src/btc.js - - -#### new Btc() *private method* - -Class for all Bitcoin based methods. - - - - - - -##### Returns - - -- `Void` - - - - ### src/blockchain.js @@ -988,12 +988,12 @@ const metrics = await web3data.blockchain.getMetrics() -### src/bsv.js +### src/btc.js -#### new Bsv() *private method* +#### new Btc() *private method* -Class for all Bitcoin SV based methods. +Class for all Bitcoin based methods. @@ -1208,32 +1208,12 @@ const code = await web3data.contract.getCode('0x06012c8cf97bead5deae237070f9587f -### src/ltc.js - - -#### new Ltc() *private method* - -Class for all Litecoin based methods. - - - - - - -##### Returns - - -- `Void` - - - - -### src/signature.js +### src/eth.js -#### new Signature() +#### new Eth() *private method* -Contains methods pertaining to the `/signatures` endpoint of Amberdata's API. +Class for all Ethereum based methods. @@ -1247,27 +1227,17 @@ Contains methods pertaining to the `/signatures` endpoint of Amberdata's API. -#### Signature.constructor(web3data) - -Creates an instance of Signature. - - +### src/ltc.js -##### Parameters -| Name | Type | Description | | -| ---- | ---- | ----------- | -------- | -| web3data | `object` | - The web3data instance. |   | +#### new Ltc() *private method* +Class for all Litecoin based methods. -##### Examples -```javascript -new Signature(new Web3Data('API_KEY')) -``` ##### Returns @@ -1277,36 +1247,6 @@ new Signature(new Web3Data('API_KEY')) -#### Signature.getSignature(hash) - -Retrieves detailed information about the specified signature hash. - - - - -##### Parameters - -| Name | Type | Description | | -| ---- | ---- | ----------- | -------- | -| hash | `string` | - The (keccak 256) of the signature. |   | - - - - -##### Examples - -```javascript -const signatureDetails = await web3data.signature.getSignature('0xe2f0a05a') -``` - - -##### Returns - - -- `Promise.<Array>` Information pertaining to the specified signature hash. - - - ### src/market.js @@ -1724,12 +1664,12 @@ const batTokenAddress = web3data.market.getAssetAddresses('bat') const assetAddr -### src/eth.js +### src/signature.js -#### new Eth() *private method* +#### new Signature() -Class for all Ethereum based methods. +Contains methods pertaining to the `/signatures` endpoint of Amberdata's API. @@ -1743,6 +1683,66 @@ Class for all Ethereum based methods. +#### Signature.constructor(web3data) + +Creates an instance of Signature. + + + + +##### Parameters + +| Name | Type | Description | | +| ---- | ---- | ----------- | -------- | +| web3data | `object` | - The web3data instance. |   | + + + + +##### Examples + +```javascript +new Signature(new Web3Data('API_KEY')) +``` + + +##### Returns + + +- `Void` + + + +#### Signature.getSignature(hash) + +Retrieves detailed information about the specified signature hash. + + + + +##### Parameters + +| Name | Type | Description | | +| ---- | ---- | ----------- | -------- | +| hash | `string` | - The (keccak 256) of the signature. |   | + + + + +##### Examples + +```javascript +const signatureDetails = await web3data.signature.getSignature('0xe2f0a05a') +``` + + +##### Returns + + +- `Promise.<Array>` Information pertaining to the specified signature hash. + + + ### src/token.js @@ -2021,29 +2021,48 @@ const transfers = await web3data.token.getTransfers('0x06012c8cf97bead5deae23707 -### src/transaction.js +### src/utils.js -#### new Transaction() +#### get(web3data, subendpoint, endpoint, hash, pathParam, filterOptions) *private method* -Contains methods pertaining to the `/address` endpoint of Amberdata's API. -See [documentation](https://docs.amberdata.io/reference#get-all-transactions) details about our transaction endpoints. +Builds the endpoint url to pass to .rawQuery(). Checks for non empties and appends +the appropriate parameter(s) where applicable. +##### Parameters + +| Name | Type | Description | | +| ---- | ---- | ----------- | -------- | +| web3data | | - Instance on which to call .rawQuery(). |   | +| subendpoint | | - The sub-endpoint. |   | +| endpoint | | - The endpoint. |   | +| hash | | - The address hash. |   | +| pathParam | | - The path parameter. |   | +| filterOptions | | - The filters associated with a given endpoint. |   | + + + + +##### Examples + +```javascript + +``` ##### Returns -- `Void` +- Returns a Promise of the rawQuery request from web3data. -#### Transaction.constructor(web3data) +#### onFulfilled(response) *private method* -Creates an instance of Transaction. Meant to be used in conjunction with the Web3Data class. +Handler for all request responses. @@ -2052,7 +2071,7 @@ Creates an instance of Transaction. Meant to be used in conjunction with the Web | Name | Type | Description | | | ---- | ---- | ----------- | -------- | -| web3data | | - The web3data instance. |   | +| response | | - The Axios response object. |   | @@ -2067,13 +2086,13 @@ Creates an instance of Transaction. Meant to be used in conjunction with the Web ##### Returns -- `Void` +- The data from the response. -#### Transaction.getTransactions(filterOptions) +#### uuid(data) *private method* -Retrieves all transactions matching the specified filters. +Generates a uuid see [this gist]() for more details. @@ -2082,9 +2101,7 @@ Retrieves all transactions matching the specified filters. | Name | Type | Description | | | ---- | ---- | ----------- | -------- | -| filterOptions | | - The filter options associated with the request. |   | -| filterOptions.status | | - Filter by the status of the transactions to retrieve (all, completed, failed, pending). |   | -| filterOptions.includePrice | | - Indicates whether or not to include price data with the results. |   | +| data | | |   | @@ -2092,24 +2109,20 @@ Retrieves all transactions matching the specified filters. ##### Examples ```javascript -const transactions = await web3data.transaction.getTransactions() -// Include pricing data with transactions -const transactions = await web3data.transaction.getTransactions({ -includePrice: true -}) + ``` ##### Returns -- All transactions matched by the specified filters. +- `Void` -#### Transaction.getAll(filterOptions) +#### getMethods(obj) *private method* -See 'getTransactions' for details. +Returns an array of methods defined on the object. @@ -2118,7 +2131,7 @@ See 'getTransactions' for details. | Name | Type | Description | | | ---- | ---- | ----------- | -------- | -| filterOptions | | |   | +| obj | | - The object from which get methods. |   | @@ -2133,13 +2146,13 @@ See 'getTransactions' for details. ##### Returns -- `Void` +- An array of method names. -#### Transaction.getTransaction(hash, filterOptions) +#### ethFactory(web3data) *private method* -Retrieves the transaction data for the specified hash. +Creates an object containing Ethereum based methods. @@ -2148,10 +2161,7 @@ Retrieves the transaction data for the specified hash. | Name | Type | Description | | | ---- | ---- | ----------- | -------- | -| hash | | - The transaction hash. |   | -| filterOptions | | - The filter options associated with the request. See [docs](https://docs.amberdata.io/reference#get-transaction) for more details. |   | -| filterOptions.validationMethod=none | | - The validation method to be added to the response: `none`, `basic`, `full`. |   | -| filterOptions.includePrice=true | | - Indicates whether or not to include price data with the results. |   | +| web3data | | - { object } The web3data instance. |   | @@ -2159,66 +2169,71 @@ Retrieves the transaction data for the specified hash. ##### Examples ```javascript -const transaction = await web3data.transaction.getTransaction('0xd0a5a0912fdf87993b3cebd696f1ee667a8fbbe8fc890a22dcbdf114f36de4cf') + ``` ##### Returns -- The data for the specified transaction hash. +- methods { object } an object containing Ethereum based methods. -#### Transaction.getPendingTransactions() +#### formatJsonRpc(options) *private method* + +Creates a string in json rpc format. -Retrieves all pending transaction. +##### Parameters + +| Name | Type | Description | | +| ---- | ---- | ----------- | -------- | +| options | | - The json rpc options. |   | + ##### Examples ```javascript -const pendingTransactions = await web3data.transaction.getPendingTransactions() + ``` ##### Returns -- The pending transactions. +- The json rpc formatted string. -#### Transaction.getGasPrediction() -Retrieves the latest gas predictions for the transactions. +### src/transaction.js +#### new Transaction() +Contains methods pertaining to the `/address` endpoint of Amberdata's API. +See [documentation](https://docs.amberdata.io/reference#get-all-transactions) details about our transaction endpoints. -##### Examples -```javascript -const gasPredictions = await web3data.transaction.getGasPrediction() -``` ##### Returns -- The latest gas predictions for the transactions. +- `Void` -#### Transaction.getGasPercentiles(filterOptions) +#### Transaction.constructor(web3data) -Retrieves the latest gas price percentiles for the transactions. +Creates an instance of Transaction. Meant to be used in conjunction with the Web3Data class. @@ -2227,8 +2242,7 @@ Retrieves the latest gas price percentiles for the transactions. | Name | Type | Description | | | ---- | ---- | ----------- | -------- | -| filterOptions | | - The filter options associated with the request. |   | -| filterOptions.numBlocks | | - Number of past blocks on which to base the percentiles. |   | +| web3data | | - The web3data instance. |   | @@ -2236,43 +2250,56 @@ Retrieves the latest gas price percentiles for the transactions. ##### Examples ```javascript -const gasPercentiles = await web3data.transaction.getGasPercentiles() + ``` ##### Returns -- The latest gas price percentiles for the transactions. +- `Void` -#### Transaction.getGasPrice() +#### Transaction.getTransactions(filterOptions) -Retrieves the latest average gas price. Uses `getGasPrediction` under the hood. +Retrieves all transactions matching the specified filters. +##### Parameters + +| Name | Type | Description | | +| ---- | ---- | ----------- | -------- | +| filterOptions | | - The filter options associated with the request. |   | +| filterOptions.status | | - Filter by the status of the transactions to retrieve (all, completed, failed, pending). |   | +| filterOptions.includePrice | | - Indicates whether or not to include price data with the results. |   | + + ##### Examples ```javascript -const gasPrice = await web3data.transaction.getGasPrice() +const transactions = await web3data.transaction.getTransactions() +// Include pricing data with transactions +const transactions = await web3data.transaction.getTransactions({ +includePrice: true +}) ``` ##### Returns -- The latest gas price. +- All transactions matched by the specified filters. -#### Transaction.getVolume(filterOptions) +#### Transaction.getAll(filterOptions) -Retrieves the historical (time series) volume of transactions. +See 'getTransactions' for details. @@ -2281,7 +2308,7 @@ Retrieves the historical (time series) volume of transactions. | Name | Type | Description | | | ---- | ---- | ----------- | -------- | -| filterOptions | | - The filter options associated with the request. See [docs](https://docs.amberdata.io/reference#get-historical-transaction-volume) for more details. |   | +| filterOptions | | |   | @@ -2289,20 +2316,20 @@ Retrieves the historical (time series) volume of transactions. ##### Examples ```javascript -const volume = await web3data.transaction.getVolume() + ``` ##### Returns -- The historical (time series) volume of transactions. +- `Void` -#### Transaction.getMetrics(filterOptions) +#### Transaction.getTransaction(hash, filterOptions) -Get metrics for recent confirmed transactions for a given blockchain. Default metrics are over a 24h period. +Retrieves the transaction data for the specified hash. @@ -2311,7 +2338,10 @@ Get metrics for recent confirmed transactions for a given blockchain. Default me | Name | Type | Description | | | ---- | ---- | ----------- | -------- | -| filterOptions | | |   | +| hash | | - The transaction hash. |   | +| filterOptions | | - The filter options associated with the request. See [docs](https://docs.amberdata.io/reference#get-transaction) for more details. |   | +| filterOptions.validationMethod=none | | - The validation method to be added to the response: `none`, `basic`, `full`. |   | +| filterOptions.includePrice=true | | - Indicates whether or not to include price data with the results. |   | @@ -2319,69 +2349,45 @@ Get metrics for recent confirmed transactions for a given blockchain. Default me ##### Examples ```javascript -const metrics = await web3data.transaction.getMetrics() +const transaction = await web3data.transaction.getTransaction('0xd0a5a0912fdf87993b3cebd696f1ee667a8fbbe8fc890a22dcbdf114f36de4cf') ``` ##### Returns -- Metrics for recent confirmed transactions. - - +- The data for the specified transaction hash. -### src/utils.js +#### Transaction.getPendingTransactions() -#### get(web3data, subendpoint, endpoint, hash, pathParam, filterOptions) *private method* +Retrieves all pending transaction. -Builds the endpoint url to pass to .rawQuery(). Checks for non empties and appends -the appropriate parameter(s) where applicable. -##### Parameters - -| Name | Type | Description | | -| ---- | ---- | ----------- | -------- | -| web3data | | - Instance on which to call .rawQuery(). |   | -| subendpoint | | - The sub-endpoint. |   | -| endpoint | | - The endpoint. |   | -| hash | | - The address hash. |   | -| pathParam | | - The path parameter. |   | -| filterOptions | | - The filters associated with a given endpoint. |   | - - - ##### Examples ```javascript - +const pendingTransactions = await web3data.transaction.getPendingTransactions() ``` ##### Returns -- Returns a Promise of the rawQuery request from web3data. - - - -#### onFulfilled(response) *private method* +- The pending transactions. -Handler for all request responses. +#### Transaction.getGasPrediction() +Retrieves the latest gas predictions for the transactions. -##### Parameters -| Name | Type | Description | | -| ---- | ---- | ----------- | -------- | -| response | | - The Axios response object. |   | @@ -2389,20 +2395,20 @@ Handler for all request responses. ##### Examples ```javascript - +const gasPredictions = await web3data.transaction.getGasPrediction() ``` ##### Returns -- The data from the response. +- The latest gas predictions for the transactions. -#### uuid(data) *private method* +#### Transaction.getGasPercentiles(filterOptions) -Generates a uuid see [this gist]() for more details. +Retrieves the latest gas price percentiles for the transactions. @@ -2411,7 +2417,8 @@ Generates a uuid see [this gist]() for more details. | Name | Type | Description | | | ---- | ---- | ----------- | -------- | -| data | | |   | +| filterOptions | | - The filter options associated with the request. |   | +| filterOptions.numBlocks | | - Number of past blocks on which to base the percentiles. |   | @@ -2419,50 +2426,43 @@ Generates a uuid see [this gist]() for more details. ##### Examples ```javascript - +const gasPercentiles = await web3data.transaction.getGasPercentiles() ``` ##### Returns -- `Void` +- The latest gas price percentiles for the transactions. -#### getMethods(obj) *private method* +#### Transaction.getGasPrice() -Returns an array of methods defined on the object. +Retrieves the latest average gas price. Uses `getGasPrediction` under the hood. -##### Parameters - -| Name | Type | Description | | -| ---- | ---- | ----------- | -------- | -| obj | | - The object from which get methods. |   | - - ##### Examples ```javascript - +const gasPrice = await web3data.transaction.getGasPrice() ``` ##### Returns -- An array of method names. +- The latest gas price. -#### ethFactory(web3data) *private method* +#### Transaction.getVolume(filterOptions) -Creates an object containing Ethereum based methods. +Retrieves the historical (time series) volume of transactions. @@ -2471,7 +2471,7 @@ Creates an object containing Ethereum based methods. | Name | Type | Description | | | ---- | ---- | ----------- | -------- | -| web3data | | - { object } The web3data instance. |   | +| filterOptions | | - The filter options associated with the request. See [docs](https://docs.amberdata.io/reference#get-historical-transaction-volume) for more details. |   | @@ -2479,20 +2479,20 @@ Creates an object containing Ethereum based methods. ##### Examples ```javascript - +const volume = await web3data.transaction.getVolume() ``` ##### Returns -- methods { object } an object containing Ethereum based methods. +- The historical (time series) volume of transactions. -#### formatJsonRpc(options) *private method* +#### Transaction.getMetrics(filterOptions) -Creates a string in json rpc format. +Get metrics for recent confirmed transactions for a given blockchain. Default metrics are over a 24h period. @@ -2501,7 +2501,7 @@ Creates a string in json rpc format. | Name | Type | Description | | | ---- | ---- | ----------- | -------- | -| options | | - The json rpc options. |   | +| filterOptions | | |   | @@ -2509,14 +2509,14 @@ Creates a string in json rpc format. ##### Examples ```javascript - +const metrics = await web3data.transaction.getMetrics() ``` ##### Returns -- The json rpc formatted string. +- Metrics for recent confirmed transactions. @@ -3145,12 +3145,12 @@ Sends unsubscription message to the websocket connection. -### src/xlm.js +### src/zec.js -#### new Xlm() *private method* +#### new Zec() *private method* -Class for all Stellar based methods. +Class for all ZCash based methods. @@ -3165,12 +3165,12 @@ Class for all Stellar based methods. -### src/zec.js +### src/xlm.js -#### new Zec() *private method* +#### new Xlm() *private method* -Class for all ZCash based methods. +Class for all Stellar based methods. diff --git a/docs/quick-start.md b/docs/quick-start.md index 24dc818..957565d 100644 --- a/docs/quick-start.md +++ b/docs/quick-start.md @@ -129,6 +129,61 @@ the hood. **Namespace**: `.eth` +
Supported Methods + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
addressblockcontractmarkettransaction
getBalancegetBlockNumbergetCodegetEtherPricegetTransaction
getBlockgetPendingTransactions
getBlockTransactionCountgetGasPrice
getTransactionFromBlock
getTransactions
getMetrics
+
+ ##### Example: ```javascript web3data.eth.address.getBalance('0x734Ac651Dd95a339c633cdEd410228515F97fAfF') @@ -164,7 +219,7 @@ web3data.eth.address.getBalance('0x734Ac651Dd95a339c633cdEd410228515F97fAfF') getTransactions getTransactions - + getMetrics getPendingTransactions @@ -213,10 +268,352 @@ web3data.btc.address.getBalance('1MUz4VMYui5qY1mxUiG8BQ1Luv6tqkvaiL') **Namespace**: `.ltc` +
Supported Methods + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
addressblocktransaction
getAllAddressesgetBlocksgetTransactions
getInformationgetBlockgetTransaction
getMetadatagetBlockNumbergetPendingTransactions
getTransactionsgetTransactionsgetMetrics
getBalancegetTransactionFromBlock
getLatestBalancegetMetrics
getHistoricalBalance
getMultipleBalances
getBalancesBatch
getMetrics
+
##### Example: ```javascript web3data.ltc.address.getBalance('LZo1qx6S5JEVh43KahTFBdvnkVFeQCz9Ze') ``` + +### Bitcoin Cash + +**Namespace**: `.bch` + +
Supported Methods + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
addressblocktransaction
getAllAddressesgetBlocksgetTransactions
getInformationgetBlockgetTransaction
getMetadatagetBlockNumbergetPendingTransactions
getTransactionsgetTransactionsgetMetrics
getBalancegetTransactionFromBlock
getLatestBalancegetMetrics
getHistoricalBalance
getMultipleBalances
getBalancesBatch
getMetrics
+
+ +##### Example: +```javascript +web3data.bch.address.getBalance('1MUz4VMYui5qY1mxUiG8BQ1Luv6tqkvaiL') +``` + +### Bitcoin SV + +**Namespace**: `.bsv` + +
Supported Methods + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
addressblocktransaction
getAllAddressesgetBlocksgetTransactions
getInformationgetBlockgetTransaction
getMetadatagetBlockNumbergetPendingTransactions
getTransactionsgetTransactionsgetMetrics
getBalancegetTransactionFromBlock
getLatestBalancegetMetrics
getHistoricalBalance
getMultipleBalances
getBalancesBatch
getMetrics
+
+ +##### Example: +```javascript +web3data.bsv.address.getBalance('1MUz4VMYui5qY1mxUiG8BQ1Luv6tqkvaiL') +``` + + +### Stellar + +**Namespace**: `.xlm` + +
Supported Methods + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
addressblocktransaction
getAllAddressesgetBlocksgetTransactions
getInformationgetBlockgetTransaction
getMetadatagetBlockNumbergetPendingTransactions
getTransactionsgetTransactionsgetMetrics
getBalancegetTransactionFromBlock
getLatestBalancegetMetrics
getHistoricalBalance
getMultipleBalances
getBalancesBatch
getMetrics
+
+ +##### Example: +```javascript +web3data.xlm.address.getBalance('GB42PDYTMHVL7FG2KQ6DGCJSEOF6RXWX7BYJ7UISU5GCRRA5DPCY2X7R') +``` + +### Zcash + +**Namespace**: `.zec` + +
Supported Methods + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
addressblocktransaction
getAllAddressesgetBlocksgetTransactions
getInformationgetBlockgetTransaction
getMetadatagetBlockNumbergetPendingTransactions
getTransactionsgetTransactionsgetMetrics
getBalancegetTransactionFromBlock
getLatestBalancegetMetrics
getHistoricalBalance
getMultipleBalances
getBalancesBatch
getMetrics
+
+ +##### Example: +```javascript +web3data.zec.address.getBalance('t1M5GSbdVpPA1XFkuzi12sJyqGkrEEfGwLJ') +``` + Note: When using the namespaced methods the blockchain Id set during instantiation will be ignored.