alchemy-sdk
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -5,3 +5,3 @@ 'use strict'; | ||
var index = require('./index-04a23af4.js'); | ||
var index = require('./index-081a0e9f.js'); | ||
require('@ethersproject/bignumber'); | ||
@@ -8,0 +8,0 @@ require('axios'); |
@@ -16,2 +16,7 @@ import { AlchemySettings, Network } from '../types/types'; | ||
readonly maxRetries: number; | ||
/** | ||
* The optional hardcoded URL to send requests to instead of using the network | ||
* and apiKey. | ||
*/ | ||
readonly url?: string; | ||
constructor(config?: AlchemySettings); | ||
@@ -18,0 +23,0 @@ /** |
import { JsonRpcProvider, CommunityResourcable } from '@ethersproject/providers'; | ||
import { Network as NetworkFromEthers, Networkish } from '@ethersproject/networks'; | ||
import { Network as NetworkFromEthers } from '@ethersproject/networks'; | ||
/** | ||
* SDK's custom implementation of ethers.js's 'AlchemyProvider'. | ||
* | ||
* Do not call this constructor directly. Instead, instantiate an instance of | ||
* {@link Alchemy} and call {@link Alchemy.config.getProvider()}. | ||
* | ||
* @public | ||
@@ -11,3 +14,2 @@ */ | ||
readonly maxRetries: number; | ||
constructor(network: Networkish, apiKey: string, maxRetries: number); | ||
/** | ||
@@ -14,0 +16,0 @@ * Overrides the method in ethers.js's `StaticJsonRpcProvider` class. This |
@@ -5,2 +5,10 @@ import { Listener } from '@ethersproject/abstract-provider'; | ||
import { CommunityResourcable, WebSocketProvider } from '@ethersproject/providers'; | ||
/** | ||
* SDK's custom implementation fo the ethers.js's 'AlchemyWebSocketProvider'. | ||
* | ||
* Do not call this constructor directly. Instead, instantiate an instance of | ||
* {@link Alchemy} and call {@link Alchemy.config.getWebSocketProvider()}. | ||
* | ||
* @public | ||
*/ | ||
export declare class AlchemyWebSocketProvider extends WebSocketProvider implements CommunityResourcable { | ||
@@ -7,0 +15,0 @@ _events: Array<EthersEvent>; |
@@ -1,2 +0,2 @@ | ||
import { BigNumberish } from '@ethersproject/bignumber'; | ||
import type { BigNumberish } from '@ethersproject/bignumber'; | ||
import { GetBaseNftsForContractOptions, GetBaseNftsForOwnerOptions, GetFloorPriceResponse, GetNftsForContractOptions, GetNftsForOwnerOptions, GetOwnersForContractResponse, GetOwnersForNftResponse, NftContractBaseNftsResponse, NftContractNftsResponse, NftTokenType, OwnedBaseNft, OwnedBaseNftsResponse, OwnedNft, OwnedNftsResponse, RefreshContractResult } from '../types/types'; | ||
@@ -3,0 +3,0 @@ import { BaseNft, Nft, NftContract } from './nft'; |
@@ -9,4 +9,5 @@ /** This is the main entry point for the library and exports user-facing API. */ | ||
export type { WebSocketNamespace } from './api/websocket-namespace'; | ||
export type { CoreNamespace } from './api/core-namespace'; | ||
export type { BaseNftContract, NftContract, Nft, BaseNft } from './api/nft'; | ||
export { fromHex, toHex, isHex } from './api/util'; | ||
export { setLogLevel, LogLevelString as LogLevel } from './util/logger'; |
@@ -18,6 +18,16 @@ import { EventType, TransactionReceipt } from '@ethersproject/abstract-provider'; | ||
maxRetries?: number; | ||
/** | ||
* Optional URL endpoint to use for all requests. Setting this field will | ||
* override the URL generated by the {@link network} and {@link apiKey} fields. | ||
* | ||
* This field is useful for testing or for using a custom node endpoint. Note | ||
* that not all methods will work with custom URLs. | ||
*/ | ||
url?: string; | ||
} | ||
/** | ||
* The supported networks by Alchemy. Note that some functions are not available | ||
* on all networks. Please refer to the Alchemy documentation for more details. | ||
* on all networks. Please refer to the Alchemy documentation for which APIs are | ||
* available on which networks | ||
* {@link https://docs.alchemy.com/alchemy/apis/feature-support-by-chain} | ||
* | ||
@@ -24,0 +34,0 @@ * @public |
@@ -11,2 +11,2 @@ /** | ||
*/ | ||
export declare function sendAxiosRequest<Req, Res>(baseUrl: string, methodName: string, params: Req): Promise<AxiosResponse<Res>>; | ||
export declare function sendAxiosRequest<Req, Res>(baseUrl: string, restApiName: string, methodName: string, params: Req): Promise<AxiosResponse<Res>>; |
@@ -8,1 +8,2 @@ import { BaseNft, BaseNftContract, Nft, NftContract } from '../api/nft'; | ||
export declare function getNftFromRaw(rawNft: RawNft, contractAddress: string): Nft; | ||
export declare const IS_BROWSER: boolean; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "1.2.0"; | ||
export declare const VERSION = "2.0.0"; |
@@ -1,4 +0,4 @@ | ||
export { A as Alchemy, c as AssetTransfersCategory, d as AssetTransfersOrder, N as Network, h as NftExcludeFilters, e as NftTokenType, R as RefreshState, f as fromHex, i as isHex, s as setLogLevel, t as toHex } from './index-7ca901e9.js'; | ||
export { A as Alchemy, c as AssetTransfersCategory, d as AssetTransfersOrder, N as Network, h as NftExcludeFilters, e as NftTokenType, R as RefreshState, f as fromHex, i as isHex, s as setLogLevel, t as toHex } from './index-969f3a91.js'; | ||
import '@ethersproject/bignumber'; | ||
import 'axios'; | ||
//# sourceMappingURL=index.js.map |
@@ -16,2 +16,7 @@ import { AlchemySettings, Network } from '../types/types'; | ||
readonly maxRetries: number; | ||
/** | ||
* The optional hardcoded URL to send requests to instead of using the network | ||
* and apiKey. | ||
*/ | ||
readonly url?: string; | ||
constructor(config?: AlchemySettings); | ||
@@ -18,0 +23,0 @@ /** |
import { JsonRpcProvider, CommunityResourcable } from '@ethersproject/providers'; | ||
import { Network as NetworkFromEthers, Networkish } from '@ethersproject/networks'; | ||
import { Network as NetworkFromEthers } from '@ethersproject/networks'; | ||
/** | ||
* SDK's custom implementation of ethers.js's 'AlchemyProvider'. | ||
* | ||
* Do not call this constructor directly. Instead, instantiate an instance of | ||
* {@link Alchemy} and call {@link Alchemy.config.getProvider()}. | ||
* | ||
* @public | ||
@@ -11,3 +14,2 @@ */ | ||
readonly maxRetries: number; | ||
constructor(network: Networkish, apiKey: string, maxRetries: number); | ||
/** | ||
@@ -14,0 +16,0 @@ * Overrides the method in ethers.js's `StaticJsonRpcProvider` class. This |
@@ -5,2 +5,10 @@ import { Listener } from '@ethersproject/abstract-provider'; | ||
import { CommunityResourcable, WebSocketProvider } from '@ethersproject/providers'; | ||
/** | ||
* SDK's custom implementation fo the ethers.js's 'AlchemyWebSocketProvider'. | ||
* | ||
* Do not call this constructor directly. Instead, instantiate an instance of | ||
* {@link Alchemy} and call {@link Alchemy.config.getWebSocketProvider()}. | ||
* | ||
* @public | ||
*/ | ||
export declare class AlchemyWebSocketProvider extends WebSocketProvider implements CommunityResourcable { | ||
@@ -7,0 +15,0 @@ _events: Array<EthersEvent>; |
@@ -1,2 +0,2 @@ | ||
import { BigNumberish } from '@ethersproject/bignumber'; | ||
import type { BigNumberish } from '@ethersproject/bignumber'; | ||
import { GetBaseNftsForContractOptions, GetBaseNftsForOwnerOptions, GetFloorPriceResponse, GetNftsForContractOptions, GetNftsForOwnerOptions, GetOwnersForContractResponse, GetOwnersForNftResponse, NftContractBaseNftsResponse, NftContractNftsResponse, NftTokenType, OwnedBaseNft, OwnedBaseNftsResponse, OwnedNft, OwnedNftsResponse, RefreshContractResult } from '../types/types'; | ||
@@ -3,0 +3,0 @@ import { BaseNft, Nft, NftContract } from './nft'; |
@@ -9,4 +9,5 @@ /** This is the main entry point for the library and exports user-facing API. */ | ||
export type { WebSocketNamespace } from './api/websocket-namespace'; | ||
export type { CoreNamespace } from './api/core-namespace'; | ||
export type { BaseNftContract, NftContract, Nft, BaseNft } from './api/nft'; | ||
export { fromHex, toHex, isHex } from './api/util'; | ||
export { setLogLevel, LogLevelString as LogLevel } from './util/logger'; |
@@ -18,6 +18,16 @@ import { EventType, TransactionReceipt } from '@ethersproject/abstract-provider'; | ||
maxRetries?: number; | ||
/** | ||
* Optional URL endpoint to use for all requests. Setting this field will | ||
* override the URL generated by the {@link network} and {@link apiKey} fields. | ||
* | ||
* This field is useful for testing or for using a custom node endpoint. Note | ||
* that not all methods will work with custom URLs. | ||
*/ | ||
url?: string; | ||
} | ||
/** | ||
* The supported networks by Alchemy. Note that some functions are not available | ||
* on all networks. Please refer to the Alchemy documentation for more details. | ||
* on all networks. Please refer to the Alchemy documentation for which APIs are | ||
* available on which networks | ||
* {@link https://docs.alchemy.com/alchemy/apis/feature-support-by-chain} | ||
* | ||
@@ -24,0 +34,0 @@ * @public |
@@ -11,2 +11,2 @@ /** | ||
*/ | ||
export declare function sendAxiosRequest<Req, Res>(baseUrl: string, methodName: string, params: Req): Promise<AxiosResponse<Res>>; | ||
export declare function sendAxiosRequest<Req, Res>(baseUrl: string, restApiName: string, methodName: string, params: Req): Promise<AxiosResponse<Res>>; |
@@ -8,1 +8,2 @@ import { BaseNft, BaseNftContract, Nft, NftContract } from '../api/nft'; | ||
export declare function getNftFromRaw(rawNft: RawNft, contractAddress: string): Nft; | ||
export declare const IS_BROWSER: boolean; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "1.2.0"; | ||
export declare const VERSION = "2.0.0"; |
@@ -1,4 +0,4 @@ | ||
export { A as Alchemy, c as AssetTransfersCategory, d as AssetTransfersOrder, N as Network, h as NftExcludeFilters, e as NftTokenType, R as RefreshState, f as fromHex, i as isHex, s as setLogLevel, t as toHex } from './index-7ca901e9.js'; | ||
export { A as Alchemy, c as AssetTransfersCategory, d as AssetTransfersOrder, N as Network, h as NftExcludeFilters, e as NftTokenType, R as RefreshState, f as fromHex, i as isHex, s as setLogLevel, t as toHex } from './index-969f3a91.js'; | ||
import '@ethersproject/bignumber'; | ||
import 'axios'; | ||
//# sourceMappingURL=index.js.map |
@@ -16,2 +16,7 @@ import { AlchemySettings, Network } from '../types/types'; | ||
readonly maxRetries: number; | ||
/** | ||
* The optional hardcoded URL to send requests to instead of using the network | ||
* and apiKey. | ||
*/ | ||
readonly url?: string; | ||
constructor(config?: AlchemySettings); | ||
@@ -18,0 +23,0 @@ /** |
import { JsonRpcProvider, CommunityResourcable } from '@ethersproject/providers'; | ||
import { Network as NetworkFromEthers, Networkish } from '@ethersproject/networks'; | ||
import { Network as NetworkFromEthers } from '@ethersproject/networks'; | ||
/** | ||
* SDK's custom implementation of ethers.js's 'AlchemyProvider'. | ||
* | ||
* Do not call this constructor directly. Instead, instantiate an instance of | ||
* {@link Alchemy} and call {@link Alchemy.config.getProvider()}. | ||
* | ||
* @public | ||
@@ -11,3 +14,2 @@ */ | ||
readonly maxRetries: number; | ||
constructor(network: Networkish, apiKey: string, maxRetries: number); | ||
/** | ||
@@ -14,0 +16,0 @@ * Overrides the method in ethers.js's `StaticJsonRpcProvider` class. This |
@@ -5,2 +5,10 @@ import { Listener } from '@ethersproject/abstract-provider'; | ||
import { CommunityResourcable, WebSocketProvider } from '@ethersproject/providers'; | ||
/** | ||
* SDK's custom implementation fo the ethers.js's 'AlchemyWebSocketProvider'. | ||
* | ||
* Do not call this constructor directly. Instead, instantiate an instance of | ||
* {@link Alchemy} and call {@link Alchemy.config.getWebSocketProvider()}. | ||
* | ||
* @public | ||
*/ | ||
export declare class AlchemyWebSocketProvider extends WebSocketProvider implements CommunityResourcable { | ||
@@ -7,0 +15,0 @@ _events: Array<EthersEvent>; |
@@ -1,2 +0,2 @@ | ||
import { BigNumberish } from '@ethersproject/bignumber'; | ||
import type { BigNumberish } from '@ethersproject/bignumber'; | ||
import { GetBaseNftsForContractOptions, GetBaseNftsForOwnerOptions, GetFloorPriceResponse, GetNftsForContractOptions, GetNftsForOwnerOptions, GetOwnersForContractResponse, GetOwnersForNftResponse, NftContractBaseNftsResponse, NftContractNftsResponse, NftTokenType, OwnedBaseNft, OwnedBaseNftsResponse, OwnedNft, OwnedNftsResponse, RefreshContractResult } from '../types/types'; | ||
@@ -3,0 +3,0 @@ import { BaseNft, Nft, NftContract } from './nft'; |
@@ -9,4 +9,5 @@ /** This is the main entry point for the library and exports user-facing API. */ | ||
export type { WebSocketNamespace } from './api/websocket-namespace'; | ||
export type { CoreNamespace } from './api/core-namespace'; | ||
export type { BaseNftContract, NftContract, Nft, BaseNft } from './api/nft'; | ||
export { fromHex, toHex, isHex } from './api/util'; | ||
export { setLogLevel, LogLevelString as LogLevel } from './util/logger'; |
@@ -18,6 +18,16 @@ import { EventType, TransactionReceipt } from '@ethersproject/abstract-provider'; | ||
maxRetries?: number; | ||
/** | ||
* Optional URL endpoint to use for all requests. Setting this field will | ||
* override the URL generated by the {@link network} and {@link apiKey} fields. | ||
* | ||
* This field is useful for testing or for using a custom node endpoint. Note | ||
* that not all methods will work with custom URLs. | ||
*/ | ||
url?: string; | ||
} | ||
/** | ||
* The supported networks by Alchemy. Note that some functions are not available | ||
* on all networks. Please refer to the Alchemy documentation for more details. | ||
* on all networks. Please refer to the Alchemy documentation for which APIs are | ||
* available on which networks | ||
* {@link https://docs.alchemy.com/alchemy/apis/feature-support-by-chain} | ||
* | ||
@@ -24,0 +34,0 @@ * @public |
@@ -11,2 +11,2 @@ /** | ||
*/ | ||
export declare function sendAxiosRequest<Req, Res>(baseUrl: string, methodName: string, params: Req): Promise<AxiosResponse<Res>>; | ||
export declare function sendAxiosRequest<Req, Res>(baseUrl: string, restApiName: string, methodName: string, params: Req): Promise<AxiosResponse<Res>>; |
@@ -8,1 +8,2 @@ import { BaseNft, BaseNftContract, Nft, NftContract } from '../api/nft'; | ||
export declare function getNftFromRaw(rawNft: RawNft, contractAddress: string): Nft; | ||
export declare const IS_BROWSER: boolean; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "1.2.0"; | ||
export declare const VERSION = "2.0.0"; |
@@ -16,2 +16,7 @@ import { AlchemySettings, Network } from '../types/types'; | ||
readonly maxRetries: number; | ||
/** | ||
* The optional hardcoded URL to send requests to instead of using the network | ||
* and apiKey. | ||
*/ | ||
readonly url?: string; | ||
constructor(config?: AlchemySettings); | ||
@@ -18,0 +23,0 @@ /** |
import { JsonRpcProvider, CommunityResourcable } from '@ethersproject/providers'; | ||
import { Network as NetworkFromEthers, Networkish } from '@ethersproject/networks'; | ||
import { Network as NetworkFromEthers } from '@ethersproject/networks'; | ||
/** | ||
* SDK's custom implementation of ethers.js's 'AlchemyProvider'. | ||
* | ||
* Do not call this constructor directly. Instead, instantiate an instance of | ||
* {@link Alchemy} and call {@link Alchemy.config.getProvider()}. | ||
* | ||
* @public | ||
@@ -11,3 +14,2 @@ */ | ||
readonly maxRetries: number; | ||
constructor(network: Networkish, apiKey: string, maxRetries: number); | ||
/** | ||
@@ -14,0 +16,0 @@ * Overrides the method in ethers.js's `StaticJsonRpcProvider` class. This |
@@ -5,2 +5,10 @@ import { Listener } from '@ethersproject/abstract-provider'; | ||
import { CommunityResourcable, WebSocketProvider } from '@ethersproject/providers'; | ||
/** | ||
* SDK's custom implementation fo the ethers.js's 'AlchemyWebSocketProvider'. | ||
* | ||
* Do not call this constructor directly. Instead, instantiate an instance of | ||
* {@link Alchemy} and call {@link Alchemy.config.getWebSocketProvider()}. | ||
* | ||
* @public | ||
*/ | ||
export declare class AlchemyWebSocketProvider extends WebSocketProvider implements CommunityResourcable { | ||
@@ -7,0 +15,0 @@ _events: Array<EthersEvent>; |
@@ -1,2 +0,2 @@ | ||
import { BigNumberish } from '@ethersproject/bignumber'; | ||
import type { BigNumberish } from '@ethersproject/bignumber'; | ||
import { GetBaseNftsForContractOptions, GetBaseNftsForOwnerOptions, GetFloorPriceResponse, GetNftsForContractOptions, GetNftsForOwnerOptions, GetOwnersForContractResponse, GetOwnersForNftResponse, NftContractBaseNftsResponse, NftContractNftsResponse, NftTokenType, OwnedBaseNft, OwnedBaseNftsResponse, OwnedNft, OwnedNftsResponse, RefreshContractResult } from '../types/types'; | ||
@@ -3,0 +3,0 @@ import { BaseNft, Nft, NftContract } from './nft'; |
@@ -9,4 +9,5 @@ /** This is the main entry point for the library and exports user-facing API. */ | ||
export type { WebSocketNamespace } from './api/websocket-namespace'; | ||
export type { CoreNamespace } from './api/core-namespace'; | ||
export type { BaseNftContract, NftContract, Nft, BaseNft } from './api/nft'; | ||
export { fromHex, toHex, isHex } from './api/util'; | ||
export { setLogLevel, LogLevelString as LogLevel } from './util/logger'; |
@@ -18,6 +18,16 @@ import { EventType, TransactionReceipt } from '@ethersproject/abstract-provider'; | ||
maxRetries?: number; | ||
/** | ||
* Optional URL endpoint to use for all requests. Setting this field will | ||
* override the URL generated by the {@link network} and {@link apiKey} fields. | ||
* | ||
* This field is useful for testing or for using a custom node endpoint. Note | ||
* that not all methods will work with custom URLs. | ||
*/ | ||
url?: string; | ||
} | ||
/** | ||
* The supported networks by Alchemy. Note that some functions are not available | ||
* on all networks. Please refer to the Alchemy documentation for more details. | ||
* on all networks. Please refer to the Alchemy documentation for which APIs are | ||
* available on which networks | ||
* {@link https://docs.alchemy.com/alchemy/apis/feature-support-by-chain} | ||
* | ||
@@ -24,0 +34,0 @@ * @public |
@@ -11,2 +11,2 @@ /** | ||
*/ | ||
export declare function sendAxiosRequest<Req, Res>(baseUrl: string, methodName: string, params: Req): Promise<AxiosResponse<Res>>; | ||
export declare function sendAxiosRequest<Req, Res>(baseUrl: string, restApiName: string, methodName: string, params: Req): Promise<AxiosResponse<Res>>; |
@@ -8,1 +8,2 @@ import { BaseNft, BaseNftContract, Nft, NftContract } from '../api/nft'; | ||
export declare function getNftFromRaw(rawNft: RawNft, contractAddress: string): Nft; | ||
export declare const IS_BROWSER: boolean; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "1.2.0"; | ||
export declare const VERSION = "2.0.0"; |
{ | ||
"name": "alchemy-sdk", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Extended Ethers.js SDK for Alchemy APIs", | ||
@@ -5,0 +5,0 @@ "author": "Alchemy", |
# Alchemy SDK for Javascript | ||
Alchemy SDK helps developers use Alchemy's APIs and endpoints more efficiently. This is a lightweight, modular SDK built as a drop-in replacement of Ethers.js that provides a superset of functionality - enabling access to the Alchemy NFT API, Websockets, and Enhanced API methods. | ||
Alchemy SDK helps developers use Alchemy's APIs and endpoints more efficiently. This is a lightweight, modular SDK built as a drop-in replacement of Ethers.js's Provider that provides a superset of functionality - enabling access to the Alchemy NFT API, Websockets, and Enhanced API methods. | ||
It also provides access to Alchemy's hardened node infrastructure, guaranteeing reliability, scalability, and quality-of-life improvements such as automatic exponential backoff retries. | ||
As of version `2.0.0` on NPM, the Alchemy SDK is out of beta. This means that all future releases will follow semantic versioning. The upgrade from `1.x.x` to `2.x.x` will be a breaking change. See the Releases changelog for full details. | ||
> :warning: **WARNING:** The `@alch/alchemy-sdk` package is now deprecated as of the v2.0.0 release. Please use the `alchemy-sdk` package instead. Note that upgrading from v1 to v2 will be a breaking change. See the changelog for full details. | ||
**IMPORTANT:** The `@alch/alchemy-sdk` package is now deprecated as of the v2.0.0 release. Please use the `alchemy-sdk` package instead. | ||
To upgrade to v2.0.0 from v1.X.X, simply run the following in your project root: | ||
To upgrade to v2.0.0 from v1.X.X, simply run one of the following: | ||
``` | ||
@@ -17,2 +16,4 @@ npm uninstall @alch/alchemy-sdk | ||
> 🙋♀️ **FEATURE REQUESTS:** We'd love your thoughts on what would improve your web3 dev process the most! If you have 5 minutes, tell us what you want at our [Feature Request feedback form](https://alchemyapi.typeform.com/sdk-feedback), and we'd love to build it for you: | ||
## Getting started | ||
@@ -32,3 +33,3 @@ | ||
apiKey: 'demo', // Replace with your Alchemy API Key. | ||
network: Network.ETH_MAINNET, // Replace with your network. | ||
network: Network.ETH_MAINNET // Replace with your network. | ||
}; | ||
@@ -41,10 +42,11 @@ | ||
## Alchemy SDK Namespaces | ||
## Using the Alchemy SDK | ||
The Alchemy SDK currently supports three different namespaces, including: | ||
- `core`: All commonly-used Ethers.js methods and Alchemy Enhanced API methods | ||
The Alchemy SDK currently supports three different namespaces, including: | ||
- `core`: All commonly-used Ethers.js Provider methods and Alchemy Enhanced API methods | ||
- `nft`: All Alchemy NFT API methods | ||
- `ws`: All WebSockets methods | ||
If you are already using Ethers.js, you should be simply able to replace the Ethers.js object with `alchemy.core` and it should just work. | ||
If you are already using Ethers.js, you should be simply able to replace the Ethers.js Provider object with `alchemy.core` and it should just work. | ||
@@ -61,3 +63,5 @@ ```ts | ||
// Access Alchemy Enhanced API requests | ||
alchemy.core.getTokenBalances("0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE").then(console.log); | ||
alchemy.core | ||
.getTokenBalances('0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE') | ||
.then(console.log); | ||
@@ -78,5 +82,5 @@ // Access the Alchemy NFT API | ||
The core package contains all commonly-used [Ethers.js](https://docs.ethers.io/v5/api/providers/api-providers/#AlchemyProvider) methods. If you are already using Ethers.js, you should be simply able to replace the Ethers.js object with `alchemy.core` and it should just work. | ||
The core package contains all commonly-used [Ethers.js Provider](https://docs.ethers.io/v5/api/providers/api-providers/#AlchemyProvider) methods. If you are already using Ethers.js, you should be simply able to replace the Ethers.js Provider object with `alchemy.core` and it should just work. | ||
It also includes the majority of Alchemy Enhanced APIs, including: | ||
It also includes the majority of Alchemy Enhanced APIs, including: | ||
@@ -88,8 +92,7 @@ - `getTokenMetadata()`: Get the metadata for a token contract address. | ||
### Accessing the full Ethers.js Provider | ||
### Accessing the full Ethers.js provider | ||
To keep the package clean, we don't support certain uncommonly-used Ethers.js Provider methods as top-level methods in the Alchemy `core` namespace - for example, `provider.formatter`. If you'd like to access these methods, simply use the `alchemy.config.getProvider()` function to configure the | ||
Ethers.js Provider [AlchemyProvider](https://docs.ethers.io/v5/api/providers/api-providers/#AlchemyProvider) and return it. | ||
To keep the package clean, we don't support certain uncommonly-used Ethers.js methods as top-level methods the Alchemy object - for example, `provider.formatter`. If you'd like to access these methods, simply use the `alchemy.config.getProvider()` function to configure the | ||
Ethers.js [AlchemyProvider](https://docs.ethers.io/v5/api/providers/api-providers/#AlchemyProvider) and return it. | ||
```ts | ||
@@ -108,3 +111,3 @@ import { Alchemy } from 'alchemy-sdk'; | ||
In addition to the built-in Ethers.js listeners, the Alchemy SDK includes support for [Alchemy's Subscription API](https://docs.alchemy.com/alchemy/enhanced-apis/subscription-api-websockets). This allows you to subscribe to events and receive updates as they occur. | ||
In addition to the built-in Ethers.js listeners, the Alchemy SDK includes support for [Alchemy's Subscription API](https://docs.alchemy.com/alchemy/enhanced-apis/subscription-api-websockets). This allows you to subscribe to events and receive updates as they occur. | ||
@@ -119,8 +122,3 @@ The `alchemy.ws` instance can be used can be used like the standard Ethers.js [WebSocketProvider](https://docs.ethers.io/v5/api/providers/other/#WebSocketProvider) to add listeners for Alchemy events: | ||
// Listen to all new pending transactions. | ||
alchemy.ws.on( | ||
{ | ||
method: 'alchemy_pendingTransactions' | ||
}, | ||
res => console.log(res) | ||
); | ||
alchemy.ws.on("block", res => console.log(res)); | ||
@@ -173,3 +171,3 @@ // Listen to only the next transaction on the USDC contract. | ||
- `refreshNftMetadata()`: Refresh the cached NFT metadata for a contract address and a single tokenId. | ||
- `refreshContract()`: Enqueues the specified contract address to have all token ids' metadata refreshed. | ||
- `refreshContract()`: Enqueues the specified contract address to have all token ids' metadata refreshed. | ||
- `getFloorPrice()`: Return the floor prices of a NFT contract by marketplace. | ||
@@ -244,3 +242,3 @@ | ||
### Getting the NFTs owned by an address | ||
### Getting the NFTs owned by an address | ||
@@ -267,5 +265,7 @@ ```ts | ||
// Filter out spam NFTs. | ||
alchemy.nft.getNftsForOwner('vitalik.eth', { | ||
excludeFilters: [NftExcludeFilters.SPAM] | ||
}).then(console.log); | ||
alchemy.nft | ||
.getNftsForOwner('vitalik.eth', { | ||
excludeFilters: [NftExcludeFilters.SPAM] | ||
}) | ||
.then(console.log); | ||
``` | ||
@@ -286,8 +286,8 @@ | ||
// Omit the NFT metadata for smaller payloads. | ||
omitMetadata: true, | ||
omitMetadata: true | ||
})) { | ||
await alchemy.nft | ||
.getOwnersForNft(nft.contract.address, nft.tokenId) | ||
.then((response) => | ||
console.log("owners:", response.owners, "tokenId:", nft.tokenId) | ||
.then(response => | ||
console.log('owners:', response.owners, 'tokenId:', nft.tokenId) | ||
); | ||
@@ -307,5 +307,5 @@ } | ||
alchemy.core.getTokenBalances('0x994b342dd87fc825f66e51ffa3ef71ad818b6893').then( | ||
console.log | ||
); | ||
alchemy.core | ||
.getTokenBalances('0x994b342dd87fc825f66e51ffa3ef71ad818b6893') | ||
.then(console.log); | ||
``` | ||
@@ -312,0 +312,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1436650
160
17231
1