# Data (*data*) ## Overview Starton Blockchain data endpoints. ### Available Operations * [getBalance](#getbalance) - Retrieve the native token balance of a specific blockchain address * [getErc20Balance](#geterc20balance) - Retrieve the ERC20 token balance for a specific address * [getGasPrice](#getgasprice) - Retrieve the current gas prices ## getBalance Checks the native balance of a given address on a specified blockchain network. ### Example Usage ```typescript import { Starton } from "@starton/sdk"; const starton = new Starton({ apiKey: "", }); async function run() { const result = await starton.data.getBalance({ address: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f", network: "polygon-mainnet", }); // Handle the result console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { StartonCore } from "@starton/sdk/core.js"; import { dataGetBalance } from "@starton/sdk/funcs/dataGetBalance.js"; // Use `StartonCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const starton = new StartonCore({ apiKey: "", }); async function run() { const res = await dataGetBalance(starton, { address: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f", network: "polygon-mainnet", }); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result); } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.GetBalanceAddressRequest](../../sdk/models/operations/getbalanceaddressrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.GetBalanceAddressResponse](../../sdk/models/operations/getbalanceaddressresponse.md)\>** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.BadRequestException | 400 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | ## getErc20Balance Fetches the balance of ERC20 tokens held by a specific address. You must specify the blockchain network, the contract address of the ERC20 token, and the address of the token holder. ### Example Usage ```typescript import { Starton } from "@starton/sdk"; const starton = new Starton({ apiKey: "", }); async function run() { const result = await starton.data.getErc20Balance({ address: "0x24cd470f549b136ec93ccd42c087124cf3ea3233", contractAddress: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f", network: "polygon-mainnet", }); // Handle the result console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { StartonCore } from "@starton/sdk/core.js"; import { dataGetErc20Balance } from "@starton/sdk/funcs/dataGetErc20Balance.js"; // Use `StartonCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const starton = new StartonCore({ apiKey: "", }); async function run() { const res = await dataGetErc20Balance(starton, { address: "0x24cd470f549b136ec93ccd42c087124cf3ea3233", contractAddress: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f", network: "polygon-mainnet", }); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result); } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.GetBalanceErc20Request](../../sdk/models/operations/getbalanceerc20request.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.GetBalanceErc20Response](../../sdk/models/operations/getbalanceerc20response.md)\>** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.BadRequestException | 400 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | ## getGasPrice Provides the current gas prices for the specified blockchain network, offering crucial information to estimate transaction costs. ### Example Usage ```typescript import { Starton } from "@starton/sdk"; const starton = new Starton({ apiKey: "", }); async function run() { const result = await starton.data.getGasPrice({ network: "polygon-mainnet", }); // Handle the result console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { StartonCore } from "@starton/sdk/core.js"; import { dataGetGasPrice } from "@starton/sdk/funcs/dataGetGasPrice.js"; // Use `StartonCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const starton = new StartonCore({ apiKey: "", }); async function run() { const res = await dataGetGasPrice(starton, { network: "polygon-mainnet", }); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result); } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.GetAllGasPriceRequest](../../sdk/models/operations/getallgaspricerequest.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.GetAllGasPriceResponse](../../sdk/models/operations/getallgaspriceresponse.md)\>** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.BadRequestException | 400 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* |