Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

alchemy-sdk

alchemyplatform315.5kMIT3.5.7TypeScript support: included

Extended Ethers.js SDK for Alchemy APIs

readme

Alchemy SDK for Javascript

The Alchemy SDK is the most comprehensive, stable, and powerful Javascript SDK available today to interact with the blockchain.

It supports the exact same syntax and functionality of the Ethers.js AlchemyProvider and WebSocketProvider, making it a 1:1 mapping for anyone using the Ethers.js Provider. However, it adds a significant amount of improved functionality on top of Ethers, such as easy access to Alchemy’s Enhanced and NFT APIs, robust WebSockets, and quality-of-life improvements such as automated retries.

The SDK leverages Alchemy's hardened node infrastructure, guaranteeing best-in-class node reliability, scalability, and data correctness, and is undergoing active development by Alchemy's engineers.

🙋‍♀️ 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 on our Feature Request feedback form, and we'd love to build it for you.

The SDK currently supports the following chains (chains with '(d)' after are deprecated):

  • Ethereum: Mainnet, Goerli (d), Sepolia, Holesky
  • Polygon: Mainnet, Mumbai (d), Amoy
  • Optimism: Mainnet, Goerli (d), Sepolia
  • Arbitrum: Mainnet, Goerli (d), Sepolia
  • Astar: Mainnet
  • PolygonZKEVM: Mainnet, Testnet(d), Cardona
  • Base: Mainnet, Goerli (d), Sepolia
  • Zksync: Mainnet, Sepolia
  • Shape: Mainnet, Sepolia
  • Linea: Mainnet, Sepolia
  • Fantom: Mainnet, Testnet
  • Zetachain: Mainnet, Testnet
  • Arbnova: Mainnet
  • Blast: Mainnet, Sepolia
  • Mantle: Mainnet, Sepolia
  • Scroll: Mainnet, Sepolia
  • Gnosis: Mainnet, Chiado
  • BNB: Mainnet, Testnet
  • Avalanche: Mainnet, Fuji
  • Celo: Mainnet, Alfajores
  • Metis: Mainnet
  • OpBNB: Mainnet, Testnet
  • Berachain: Mainnet, Bartio
  • Soneium: Mainnet, Minato
  • Worldchain: Mainnet, Sepolia
  • Rootstock: Mainnet, Testnet
  • Flow: Mainnet, Testnet
  • Zora: Mainnet, Sepolia
  • Frax: Mainnet, Sepolia
  • Polynomial: Mainnet, Sepolia
  • Crossfi: Mainnet, Testnet
  • Apechain: Mainnet, Curtis
  • Lens: Sepolia
  • Geist: Mainnet, Polter
  • Lumia: Prism, Testnet
  • Unichain: Mainnet, Sepolia
  • Sonic: Mainnet, Blaze
  • XMTP: Testnet
  • Abstract: Mainnet, Testnet
  • Degen: Mainnet
  • Ink: Mainnet, Sepolia
  • Sei: Mainnet, Testnet
  • Ronin: Mainnet, Saigon
  • Monad: Testnet
  • Settlus: Testnet (Sepolia)

You can find per-method documentation of the Alchemy SDK endpoints at the Alchemy Docs linked in the sidebar.

Getting started

npm install alchemy-sdk

After installing the app, you can then import and use the SDK:

import { Alchemy, Network } from 'alchemy-sdk';

// Optional config object, but defaults to the API key 'demo' and Network 'eth-mainnet'.
const settings = {
  apiKey: 'demo', // Replace with your Alchemy API key.
  network: Network.ETH_MAINNET // Replace with your network.
};

const alchemy = new Alchemy(settings);

ℹ️ Creating a unique Alchemy API Key

The public "demo" API key may be rate limited based on traffic. To create your own API key, sign up for an Alchemy account here and use the key created on your dashboard for the first app.

The Alchemy object returned by new Alchemy() provides access to the Alchemy API. An optional config object can be passed in when initializing to set your API key, change the network, or specify the max number of retries.

Using the Alchemy SDK

The Alchemy SDK currently supports the following namespaces:

  • core: All commonly-used Ethers.js Provider methods and Alchemy Enhanced API methods
  • nft: All Alchemy NFT API methods
  • ws: All WebSockets methods
  • transact: All Alchemy Transaction API methods
  • notify: CRUD endpoints for modifying Alchemy Notify Webhooks
  • debug: Methods to inspect and replay transactions and blocks

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 work properly.

ℹ️ ENS Name Resolution

The Alchemy SDK now supports ENS names (e.g. vitalik.eth) for every parameter where you can pass in a Externally Owned Address, or user address (e.g. 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045).

import { Alchemy, AlchemySubscription } from 'alchemy-sdk';

// Using default settings - pass in a settings object to specify your API key and network
const alchemy = new Alchemy();

// Access standard Ethers.js JSON-RPC node request
alchemy.core.getBlockNumber().then(console.log);

// Access Alchemy Enhanced API requests
alchemy.core
  .getTokenBalances('0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE')
  .then(console.log);

// Access the Alchemy NFT API
alchemy.nft.getNftsForOwner('vitalik.eth').then(console.log);

// Access WebSockets and Alchemy-specific WS methods
alchemy.ws.on(
  {
    method: AlchemySubscription.PENDING_TRANSACTIONS
  },
  res => console.log(res)
);

The Alchemy SDK also supports a number of Ethers.js objects that streamline the development process:

  • Utils: Equivalent to ethers.utils, this provides a number of common Ethers.js utility methods for developers.
    • Interface: Found in Utils.Interface, this class abstracts the encoding and decoding required to interact with contracts on the Ethereum network.
  • Contract: An abstraction for smart contract code deployed to the blockchain.
  • ContractFactory: Allows developers to build a Contract object.
  • Wallet: An implementation of Signer that can sign transactions and messages using a private key as a standard Externally Owned Account.

Alchemy Settings

An AlchemySettings object can be passed on instantiation to the Alchemy object, with the following optional parameters:

  • apiKey: API key that can be found in the Alchemy dashboard. Defaults to demo: a rate-limited public key.
  • network: Name of the network. Defaults to Network.ETH_MAINNET
  • maxRetries: The maximum number of retries to attempt if a request fails. Defaults to 5.
  • url: Optional URL endpoint to use for all requests. Setting this field will override the URL generated by the network andapiKey fields.
  • authToken: Alchemy auth token required to use the Notify API. This token can be found in the Alchemy Dashboard on the Notify tab.
  • batchRequests: Optional setting that automatically batches and sends json-rpc requests for higher throughput and reduced network IO. Defaults to false.
  • requestTimeout: Optional setting that sets the timeout for requests in milliseconds for the NFT and Notify namespaces. Defaults to no timeout.

Alchemy Core

The core namespace contains all commonly-used Ethers.js Provider methods. If you are already using Ethers.js, you should be simply able to replace the Ethers.js Provider object with alchemy.core when accessing provider methods and it should just work.

It also includes the majority of Alchemy Enhanced APIs, including:

  • getTokenMetadata(): Get the metadata for a token contract address.
  • getTokenBalances(): Gets the token balances for an owner given a list of contracts.
  • getAssetTransfers(): Get transactions for specific addresses.
  • getTransactionReceipts(): Gets all transaction receipts for a given block.

You will also find the following utility methods:

  • findContractDeployer(): Find the contract deployer and block number for a given contract address.
  • getTokensForOwner(): Get all token balances and metadata for a given owner address

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 and return it.

import { Alchemy } from 'alchemy-sdk';

const alchemy = new Alchemy();

async function runAlchemy() {
  const ethersProvider = await alchemy.config.getProvider();
  console.log(ethersProvider.formatter);
}
runAlchemy();

Alchemy WebSockets

In addition to the built-in Ethers.js listeners, the Alchemy SDK includes support for Alchemy's Subscription API. This allows you to subscribe to events and receive updates as they occur.

The alchemy.ws instance can be used like the standard Ethers.js WebSocketProvider to add listeners for Alchemy events:

import { Alchemy, AlchemySubscription } from 'alchemy-sdk';

const alchemy = new Alchemy();

// Listen to all new pending transactions.
alchemy.ws.on('block', res => console.log(res));

// Listen to only the next transaction on the USDC contract.
alchemy.ws.once(
  {
    method: AlchemySubscription.PENDING_TRANSACTIONS,
    toAddress: 'vitalik.eth'
  },
  res => console.log(res)
);

// Remove all listeners.
alchemy.ws.removeAllListeners();

The SDK brings multiple improvements to ensure correct WebSocket behavior in cases of temporary network failure or dropped connections. As with any network connection, you should not assume that a WebSocket will remain open forever without interruption, but correctly handling dropped connections and reconnection by hand can be challenging to get right. The Alchemy SDK automatically handles these failures with no configuration necessary. The main benefits are:

  • Resilient event delivery: Unlike standard Web3.js or Ethers.js, you will not permanently miss events which arrive while the backing WebSocket is temporarily down. Instead, you will receive these events as soon as the connection is reopened. Note that if the connection is down for more than 120 blocks (approximately 20 minutes), you may still miss some events that were not part of the most recent 120 blocks.
  • Lowered rate of failure: Compared to standard Web3.js or Ethers.js, there are fewer failures when sending requests over the WebSocket while the connection is down. The Alchemy SDK will attempt to send the requests once the connection is reopened. Note that it is still possible, with a lower likelihood, for outgoing requests to be lost, so you should still have error handling as with any network request.

Alchemy Transact

The transact namespace contains methods used for simulating and sending transactions. The unique methods to the transact namespace are:

  • sendPrivateTransaction(): Send a private transaction through Flashbots.
  • cancelPrivateTransaction(): Cancel a private transaction sent with Flashbots.
  • simulateAssetChanges(): Simulate a transaction and get a list of asset changes.
  • simulateExecution(): Simulate a transaction and get a full list of internal transactions, logs, ABI decoded results and more.
  • simulateAssetChangesBundle(): Simulate a list of transactions in sequence and get a list of asset changes.
  • simulateExecutionBundle(): Simulate a list of transactions in sequence and get a full list of internal transactions, logs, ABI decoded results and more.

The transact namespace also aliases over several commonly used methods from the core namespace for convenience:

  • getTransaction(): Returns the transaction for the given transaction hash.
  • sendTransaction(): Sends a standard transaction to the network to be mined.
  • waitForTransaction(): Waits for a transaction to be mined and returns the transaction receipt.

Alchemy NFT API

The SDK currently supports the following NFT API endpoints under the alchemy.nft namespace:

  • getNftMetadata(): Get the NFT metadata for an NFT contract address and tokenId.
  • getNftMetadataBatch(): Get the NFT metadata for multiple NFT contract addresses/token id pairs.
  • getContractMetadata(): Get the metadata associated with an NFT contract
  • getContractMetadataBatch(): Get the metadata associated with multiple NFT contracts in a single request.
  • getContractsForOwner(): Get all NFT contracts that the provided owner address owns.
  • getNftsForOwner(): Get NFTs for an owner address.
  • getNftsForOwnerIterator(): Get NFTs for an owner address as an async iterator (handles paging automatically).
  • getNftsForContract(): Get all NFTs for a contract address.
  • getNftsForContractIterator(): Get all NFTs for a contract address as an async iterator (handles paging automatically).
  • getOwnersForNft(): Get all the owners for a given NFT contract address and a particular token ID.
  • getOwnersForContract(): Get all the owners for a given NFT contract address.
  • getMintedNfts(): Get all the NFTs minted by the owner address.
  • getTransfersForOwner(): Get all the NFT transfers for a given owner address.
  • getTransfersForContract(): Get all the NFT transfers for a given NFT contract address.
  • verifyNftOwnership(): Check whether the provided owner address owns the provided NFT contract addresses.
  • isSpamContract(): Check whether the given NFT contract address is a spam contract as defined by Alchemy (see the NFT API FAQ)
  • getSpamContracts(): Returns a list of all spam contracts marked by Alchemy.
  • reportSpam(): Report feedback that a given NFT contract address is a spam contract as defined by Alchemy.
  • isAirdropNft(): Check whether the given NFT token is marked as an airdrop or not. Airdrops are defined as NFTs that were minted to a user address in a transaction sent by a different address.
  • 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.
  • getFloorPrice(): Return the floor prices of a NFT contract by marketplace.
  • computeRarity(): Get the rarity of each attribute of an NFT.
  • getNftSales(): Returns NFT sales that have happened through on-chain marketplaces.
  • summarizeNftAttributes(): Get the summary of attribute prevalence for all NFTs in a contract.
  • searchContractMetadata(): Search for a keyword across metadata of all ERC-721 and ERC-1155 smart contracts.

Pagination

The Alchemy NFT endpoints return 100 results per page. To get the next page, you can pass in the pageKey returned by the previous call. To simplify paginating through all results, the SDK provides the getNftsIterator() and getNftsForContractIterator() functions that automatically paginate through all NFTs and yields them via an AsyncIterable.

Here's an example of how to paginate through all the NFTs in Vitalik's ENS address:

import { Alchemy } from 'alchemy-sdk';

const alchemy = new Alchemy();

async function main() {
  const ownerAddress = 'vitalik.eth';
  for await (const nft of alchemy.nft.getNftsForOwnerIterator(ownerAddress)) {
    console.log('ownedNft:', nft);
  }
}

main();

SDK vs API Differences

The NFT API in the SDK standardizes response types to reduce developer friction, but note this results in some differences compared to the Alchemy REST endpoints:

  • Methods referencing Collection have been renamed to use the name Contract for greater accuracy: e.g. getNftsForContract.
  • Some methods have different naming that the REST API counterparts in order to provide a consistent API interface ( e.g. getNftsForOwner() is alchemy_getNfts, getOwnersForNft() is alchemy_getOwnersForToken).
  • SDK standardizes to omitMetadata parameter (vs. withMetadata).
  • Standardization to pageKey parameter for pagination (vs. nextToken/startToken)
  • Empty TokenUri fields are omitted.
  • Token ID is always normalized to an integer string on BaseNft and Nft.
  • Some fields omitted in the REST response are included in the SDK response in order to return an Nft object.
  • Some fields in the SDK's Nft object are named differently than the REST response.

Alchemy Notify

The Alchemy Notify API helps developers set up webhooks in their apps. The namespace provides methods to programmatically create, read, update, and delete your webhooks along with typings for the different webhooks. To learn more about Webhooks, please refer to the Alchemy documentation.

Methods on the NotifyNamespace can be accessed via alchemy.notify. To use the methods, you must include your team's auth token in the authToken field of AlchemySettings when instantiating the SDK. The auth token can be found on the Alchemy Dashboard in the Notify Tab.

Methods include:

  • getAllWebhooks(): Get all webhooks on your team.
  • getAddresses(): Get all addresses tracked for the provided Address Activity Webhook.
  • getNftFilters(): Get all NFT filters tracked for the provided NFT Activity Webhook.
  • createWebhook(): Create a new webhook.
  • updateWebhook(): Update an existing webhook's active status or tracked addresses and NFT filters.
  • deleteWebhook(): Delete the provided webhook.

Alchemy Debug

Methods on the DebugNamespace can be accessed via alchemy.debug. These methods are used for inspecting and debugging transactions.

Methods include:

  • traceCall(): Run an eth_call with the context of the provided block execution using the final state of the parent block as the base.
  • traceTransaction(): Run the transaction in the exact same manner as it was executed on the network. It will replay any transaction that may have been executed prior to this one before it and will then attempt to execute the transaction that corresponds to the given hash.
  • traceBlock(): Replay a block that has already been mined.

Documentation

The SDK is documented via tsdoc comments in the source code. The generated types and documentation are included when using an IDE. To browse the documentation separately, you can view the generated API interfaces in etc/alchemy-sdk.api.md. You can view generated Markdown files for each endpoint in the docs-md directory, or as a webpage by opening docs/index.html in your browser.

Usage Examples

Below are a few usage examples.

*ℹ️ More Examples *

You can also go here: Examples Using the Alchemy SDK.

Getting the NFTs owned by an address

import { Alchemy, NftExcludeFilters } from 'alchemy-sdk';

const alchemy = new Alchemy();

// Get how many NFTs an address owns.
alchemy.nft.getNftsForOwner('vitalik.eth').then(nfts => {
  console.log(nfts.totalCount);
});

// Get all the image urls for all the NFTs an address owns.
async function main() {
  for await (const nft of alchemy.nft.getNftsForOwnerIterator('vitalik.eth')) {
    console.log(nft.media);
  }
}

main();

// Filter out spam NFTs.
alchemy.nft
  .getNftsForOwner('vitalik.eth', {
    excludeFilters: [NftExcludeFilters.SPAM]
  })
  .then(console.log);

Getting all the owners of the BAYC NFT

import { Alchemy } from 'alchemy-sdk';

const alchemy = new Alchemy();

// Bored Ape Yacht Club contract address.
const baycAddress = '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D';

async function main() {
  for await (const nft of alchemy.nft.getNftsForContractIterator(baycAddress, {
    // Omit the NFT metadata for smaller payloads.
    omitMetadata: true
  })) {
    await alchemy.nft
      .getOwnersForNft(nft.contract.address, nft.tokenId)
      .then(response =>
        console.log('owners:', response.owners, 'tokenId:', nft.tokenId)
      );
  }
}

main();

Get all outbound transfers for a provided address

import { Alchemy } from 'alchemy-sdk';

const alchemy = new Alchemy();

alchemy.core.getTokenBalances('vitalik.eth').then(console.log);

Questions and Feedback

If you have any questions, issues, or feedback, please file an issue on GitHub, or drop us a message on our Discord channel for the SDK.

changelog

Changelog for Alchemy SDK for JavaScript

Unreleased

Major Changes

Minor Changes

3.5.7

Minor Changes

  • Added Solana address activity webhook
  • Added animation to NFT type
  • Added name to create-webhook

3.5.6

Minor Changes

  • Added MONAD testnet.
  • Added SETTLUS testnet (Sepolia).

3.5.5

Minor Changes

  • Added SEI mainnet.

3.5.4

Major Changes

Minor Changes

  • Added RONIN mainnet, testnet (Saigon).

3.5.3

Major Changes

Minor Changes

  • Added ABSTRACT mainnet.
  • Added UNICHAIN mainnet.
  • Added SEI testnet.

3.5.2

Minor Changes

  • Added BERACHAIN mainnet.

3.5.1

Minor Changes

  • Added many new networks

3.5.0

Major Changes

  • Added a new PricesNamespace with three new methods: getTokenPriceByAddress(), getTokenPriceBySymbol(), getHistoricalPriceByAddress, and getHistoricalPriceBySymbol(). Access these methods via alchemy.prices.

3.4.8

Minor Changes

  • Added networks for FLOW.

3.4.7

Minor Changes

  • Added networks for ROOTSTOCK.

3.4.6

Minor Changes

  • Fixed webhook network parsing in getAllWebhooks method for all supported networks.

3.4.5

Minor Changes

  • Fixed createWebhook's skip_empty_messages param.

3.4.4

Minor Changes

  • Added networks for WORLDCHAIN.

3.4.3

Minor Changes

  • Added networks for SONEIUM and BERACHAIN. Note that these are primarily for CoreNamespace methods. Not all namespaces will work with these networks.

3.4.2

Minor Changes

  • Addressed security vulnerabilities by adding overrides for elliptic and ws dependencies. Specifically:
    • Updated elliptic to version 6.5.7 (latest) to fix vulnerabilities related to EDDSA signature length checks and ECDSA BER-encoded signatures.
    • Updated ws to version 7.5.10 to mitigate a potential DoS vulnerability. The latest major version of ws is 8.x, however, 7.5.10 is the most up-to-date version compatible with ethers v5, which depends on 7.x versions of ws.

3.4.1

Minor Changes

  • Fixed a bug where the openSeaMetadata?.safelistRequestStatus was undefined in the Nft object that resulted in a Cannot read properties of undefined error (#416)

3.4.0

Major Changes

  • Added networks for SHAPE, LINEA, FANTOM, ZETACHAIN, ARBNOVA, BLAST, MANTLE, SCROLL, GNOSIS, BNB, AVAX, CELO, METIS, OPBNB. Note that these are primarily for CoreNamespace methods. Not all namespaces will work these networks.
  • App IDs are now a required property when calling NotifyNamespace.createWebhook() with WebhookType.GRAPHQL. This is not a Typescript breaking change, but rather a run-time breaking change. Calling the endpoint without an App ID will now throw an error instead of returning a 503.

Minor Changes

  • Fixed a bug with NotifyNamespace.createWebhook() when using WebhookType.GRAPHQL. Also added the option use skipEmptyMessages when creating graphQL webhooks to skip empty blocks.
  • Updated axios version to remove security warning (#443).

3.3.1

Minor Changes

  • Fixed a bug where the openSeaMetadata?.safelistRequestStatus was undefined in the Nft object that resulted in a Cannot read properties of undefined error (#416)
  • Added support connectionInfoOverrides field in the Alchemy constructor. This allows you to override the ethers.js ConnectionInfo object and specify custom connection information for the underlying JsonRpcProvider.

3.3.0

Major Changes

  • Added support for Zksync Mainnet and Sepolia via the Network.ZKSYNC_MAINNET and Network.ZKSYNC_SEPOLIA enums.

Minor Changes

3.2.1

Major Changes

  • Added support for Arbitrum and Optimism Sepolia webhook creation.

Minor Changes

  • API error messages return the actual error instead of [Object object]

3.2.0

Major Changes

  • Added support for Polygon Amoy network via the Network.MATIC_AMOY enum.

Minor Changes

3.1.2

Major Changes

Minor Changes

  • Upgraded the axios dependency to v1.6.5, fixing a vulnerable version #397. Thanks @mpsq for the contribution!

3.1.1

Major Changes

Minor Changes

  • Added endpoints for isAirdropNft() and reportSpam() in NftNamespace.
  • Added a missing marketplaceAddress field to the NftSale in NftNamespace.getNftSales().
  • Fixed an incorrect field name for bannerImageUrl in OpenSeaCollectionMetadata. Deprecated the old field name imageBannerUrl.
  • Added support for Base networks in NotifyNamespace.

3.1.0

Major Changes

  • Added support for Optimism Sepolia and Base Sepolia via the Network.OPT_SEPOLIA and Network.BASE_SEPOLIA enums.

Minor Changes

3.0.0

Major Changes

2.11.0

Minor Changes

  • Added support for Arbitrum Sepolia network via the Network.ARB_SEPOLIA enum.

2.10.1

Major Changes

Minor Changes

  • Fixed a bug in the Log object where the removed field was not included in the response.

2.10.0

Major Changes

  • Add support for Base

Minor Changes

2.9.2

Major Changes

  • Added a new method CoreNamespace.isContractAddress() to easily check if an address is a contract or EOA. The method accepts a string address and returns a boolean value indicating if the given address is a contract address or not.

Minor Changes

  • Fixed a bug where GetOwnersForContractResponse was missing the pageKey field.

2.9.1

Major Changes

Minor Changes

  • Add the refreshCache parameter to NFT rarity endpoints to allow users to update stale rarity values.
  • Add the includeCount parameter to getOwnersForContract.

2.9.0

Major Changes

  • Fixed a bug with in NftNamespace.getNftSales() in which there was a typo in decimal field of the NftSaleFeeData object. The field is now correctly named decimals, and decimal is marked deprecated to avoid a breaking change.

Minor Changes

  • Added redundancy to CoreNamespace.getTokensForOwner() to handle failures when fetching token metadata.
  • Added support for the acquiredAt field for ordered getNftsForOwner queries. Only available when specifying orderBy: NftOrdering.TRANSFERTIME in the request.
  • Added the NftSaleMarketplace.BLUR marketplace enum to the NftNamespace.getNftSales() method return.
  • Added support for the validAt response field to NftNamespace.getNftSales().

2.8.3

Major Changes

Minor Changes

  • Fixed a bug with NotifyNamespace when creating webhooks on ETH_SEPOLIA, OPT_GOERLI, and ARB_GOERLI.
  • Fixed a bug with Wallet.populateTransaction() where the method would never resolve.
  • Fixed a bug with NftNamespace.getMintedNfts() and NftNamespace.getTransfersForOwner() where the method would always throw an error for certain addresses (#318).

2.8.2

Major Changes

Minor Changes

  • Moved the exports.default field to be the last field. This fixed a bug introduced in 2.8.1 that prevented certain frameworks from building (#313).

2.8.1

Major Changes

Minor Changes

  • Fixed a bug where the SDK was not compatible with moduleResolution: bundler when using typescript at v5.0(#302). Thanks @florrdv!
  • Fixed a bug with getTransfersForOwner() and getTransfersForContract() methods in the NftNamespace, where some NFTs would not be returned if the NFT was transferred multiple times.

2.8.0

Major Changes

Added PolygonZkEvm Mainnet and Testnet limited support to the sdk

Minor Changes

2.7.0

Major Changes

  • Added CustomGraphqlWebhook to be used with the NotifyNamespace. This webhook uses graphql to track any event on every block.

Minor Changes

2.6.3

Major Changes

Minor Changes

  • Added support for a pageKey and pageSize parameter in NftNamespace.getOwnersforNft to allow for pagination of the results.

2.6.2

Major Changes

Minor Changes

  • Added additional descriptive tokenTypes in NFT- and contract-level metadata, for contracts which don't support any NFT standard.

2.6.1

Major Changes

Minor Changes

  • Added the title field to ContractForOwner to represent the title of the token held by the owner.
  • Fixed a bug where the media field in ContractForOwner was a Media object rather than a Media[] array.
  • Added support for the Eth Sepolia network via the Network.ETH_SEPOLIA enum.

2.6.0

Major Changes

  • Added the NftMetadataUpdateWebhook to be used with the NotifyNamespace. This webhook tracks all ERC721 and ERC1155 token metadata updates.

Minor Changes

2.5.0

Major Changes

  • Added TransactNamespace.simulateAssetChangesBundle() to simulate a list of transactions in sequence and return a list of asset changes.
  • Added TransactNamespace.simulateExecutionBundle() to simulate a list of transactions in sequence and return a list of decoded logs and traces.
  • Added NftNamespace.getContractMetadataBatch() to get the metadata associated with multiple NFT contracts in a single request.

Minor Changes

  • Added exports for Ethers.js types and interfaces used by the SDK.
  • Added the pageSize parameter to the NftNamespace.getContractsForOwner() method.

2.4.3

Major Changes

Minor Changes

  • Added a missing gas field in the DebugTransaction interface to specify the gas provided for a transaction execution.
  • Fixed a bug with NftNamespace.getMintedNfts(), NftNamespace.getTransfersForOwner(), and NftNamespace.getTransfersForContract() where the method would incorrectly error if the specified address had no transfers.
  • Added the BigNumber ethers export. You can access this by importing BigNumber along with the other exports in the package.

2.4.2

Major Changes

Minor Changes

  • Added the CoreNamespace.getTokensForOwner() method to get all the token balances and token metadata for a given address.
  • Added the wyvern and cryptopunks marketplaces in the NftSaleMarketplace enum to the NftNamespace.getNftSales() method.
  • Added the blockHash field to the OwnedNftsResponse returned by NftNamespace.getNftsForOwner() to track the block hash that the request was based on.

2.4.1

Major Changes

Minor Changes

  • Added the NftNamespace.getTransfersForOwner() method to get all NFT transfers to or from a provided owner address.
  • Added the NftNamespace.getTransfersForContract() method to all the NFT transfers for a provided NFT contract address.
  • Deprecated the GetMintedNftsResponse interface in favor of the TransfersNftResponse. The TransfersNftResponse contains the same properties as the GetMintedNftsResponse and includes additional fields about the transfer.

2.4.0

Major Changes

  • Added TransactNamespace.simulateAssetChanges() to simulate a transaction and return a list of asset changes.
  • Added TransactNamespace.simulateExecution() to simulate a transaction and return a list of decoded logs and traces.

Minor Changes

2.3.1

Major Changes

Minor Changes

  • Added support for passing in a null tokenId when using NFT Webhook Filters, which allows you to listen to all token ids in a collection.
  • Added NftNamespace.getMintedNfts() to fetch all the NFTs an owner address minted, optionally filtered by a set of specific NFT contracts.
  • Added the option to pass in an EventFilter with multiple addresses to the CoreNamespace.getLogs() method.
  • Fixed a bug where the protocolFee was not included in the response for NftNamespace.getNftSales(). Deprecated the existing marketplaceFee property in favor of the new protocolFee property.

2.3.0

Major Changes

  • Added the DebugNamespace to the top-level Alchemy object. The DebugNamespace is used to replay and inspect transactions and mined blocks in greater detail.

Minor Changes

  • Added the tokenUriTimeoutInMs option to NftNamespace.getNftsForContract() to specify the timeout duration for fetching an NFT's underlying metadata.
  • Fixed a bug where using AlchemySubscriptions.PENDING_TRANSACTIONS with a string array input would throw an error (#222).
  • Added support for the refreshCache option in NftNamespace.getNftMetadata(). This option is now available when using the options overload. The original method without the options overload is now deprecated.
  • Added support for the requestTimeout option in the AlchemySettings object to configure a timeout for NftNamespace and NotifyNamespace methods. Thanks @Abbaskt!
  • Added the contractDeployer and deployedBlockNumber into the NftContract object. Methods that return NFTs such as NftNamespace.getNftsForOwner() and NftNamespace.getContractsForOwner() now include this information under the contract field.

2.2.5

Major Changes

  • Added NftNamespace.getContractsForOwner() to fetch all NFT contracts for a specified owner address.

Minor Changes

  • Fixed a bug in NftNamespace.getNftsForOwner() where the openSea metadata was not included in the returned NFT.
  • Marked the NftExcludeFilters type as deprecated. Please use NftFilters instead.
  • Added support for the orderBy param to NftNamespace.getNftsForOwner() and NftNamespace.getContractsForOwner().

2.2.4

Major Changes

Minor Changes

  • Fixed a bug where newHeads subscriptions would error and crash when reconnecting to the websocket.
  • Fixed a bug where certain subscriptions would not reconnect after the websocket reconnected.
  • Added exports for toUtf8Bytes and toUtf8String in Utils.

2.2.3

Major Changes

Minor Changes

  • Fixed a typo with the AlchemySettings.batchRequests property.

2.2.2 (DEPRECATED)

Major Changes

Minor Changes

  • Added support for ENS resolution to the NotifyNamespace and WebsocketNamespace methods.
  • Added the batchRequests setting in AlchemySettings. Enabling this setting will automatically batch and send json-rpc requests to reduce network overhead.
  • Included new export for the Interface class from ethers to simplify encoding ABI when using eth_call.
  • Added support for the NftNamespace.getNftMetadataBatch() method to fetch metadata for multiple NFTs in a single call.
  • Added support for the NftNamespace.getNftSales() method to fetch NFT sales across different marketplaces. Thanks @xeno097!

2.2.1

Major Changes

Minor Changes

  • Fixed a bug where AlchemyConfig.getWebsocketProvider() was not exported as a public method. This method allows you get the underlying WebsocketProvider that is implemented by ethers.
  • Added the NftNamespace.summarizeNftAttributes() method to get the summary of attribute prevalence for all NFTs in a contract.
  • Added the NftNamespace.searchContractMetadata() method to search for a keyword across ERC721 and ERC1155 contract metadata.
  • Added support for ENS resolution on several CoreNamespace methods. You should now be able to pass in an ENS domain into any param that requires an owner address.
  • Added the CoreNamespace.resolveName() and CoreNamespace.lookupAddress() methods to resolve and lookup ENS domains and their owner addresses.
  • Fixed a bug where the Accept-Encoding header was incorrectly included in requests that originated from the browser (#174).
  • Added the openSea response to NftNamespace.getContractMetadata()to match the REST endpoint (#162).

2.2.0

Major Changes

  • Added the NotifyNamespace to the top-level Alchemy object. The NotifyNamespace is used to perform CRUD operations on webhooks in the Notify API.
  • Added the alchemy_minedTransactions subscription event to the WebsocketNamespace. This subscription emits full transaction objects or hashes that are mined on the network based on provided filters.
  • Added the NftNamespace.computeRarity() method to get the rarity attributes of the provided NFT. Thanks @xeno097!

Minor Changes

2.1.1

Minor Changes

  • Added the AIDROPS enum to NftNamespace.getNftsForOwner().
  • Added the spamInfo field to the response for getNftsForOwner() and getNftsForContract().
  • Fixed a bug where type declarations were not available when using NodeNext module resolution. Thanks @quentinverlhac!
  • Marked Ropsten, Rinkeby, and Kovan Network enums as deprecated. Please switch over to Sepolia.

2.1.0

Major Changes

  • POTENTIALLY BREAKING: Fixed a typing bug where the totalSupply field in an NftContract should have type string instead of number.
  • Updated the Nft class to include the contract metadata in the Nft.contract field.
  • Added commonly used utility methods from ethers.js into a top-level Utils export.
  • Added the NftNamespace.verifyNftOwnership() method to replace the deprecated checkNftOwnership() method.
  • Added Contract and ContractFactory exports from ethers into the top-level exports.

Minor Changes

  • Added support for withTokenBalances in NftNamespace.getOwnersForContract().
  • Added support for the erc20 token type and pagination for CoreNamespace.getTokenBalances().
  • Added bytes field to the Media object in the NFT metadata responses to indicate the size of the media in bytes. Note that the size field is not supported by the backend and will be removed in the next version.

2.0.4

Minor Changes

  • Added a size field to the Media object in the NFT metadata responses to indicate the size of the media in bytes.
  • Bumped @ethersproject dependencies to v5.7.0 to support safe and finalized blocks.

2.0.3

Minor Changes

  • Added support for the pageSize parameter in GetNftsForOwnerOptions to specify the number of NFTs fetched when using alchemy.nft.getNftsForOwner().
  • Added support for a Wallet object. This object is identical to the Ethers Wallet class.
  • Added support for Arbitrum Goerli network via the Network.ARB_GOERLI enum.
  • Added support for the AStar Mainnet network via the Network.ASTAR_MAINNET enum.
  • Added typed request/response overloads for CoreNamespace.getAssetTransfers() for when the withMetadata param is true.
  • Added support the tokenUriTimeoutInMs parameter on getNftsForOwner(), getNftMetadata(), and getNftsForContract().

2.0.2

Major Changes

  • Added the transact namespace for functionality relating to sending transactions. This includes the Flashbots methods sendPrivateTransaction and cancelPrivateTransaction.

Minor Changes

  • Removed the deprecated TOKEN enum from AssetTransfersCategory.
  • Added support for Optimism Goerli network via the Network.OPT_GOERLI enum.
  • Added the pageSize parameter in GetNftsForContractOptions to specify the number of NFTs fetched when using alchemy.nft.getNftsForContract.
  • Added correct withMetadata typing to AssetTransfersResponse.

2.0.1

Minor Changes

  • Added an optional url setting to AlchemySettings to allow specifying a custom hardcoded URL to send all requests to.
  • Fixed a bug where the SDK would incorrectly include a gzip header in browser environments

2.0.0

Major Changes

  • Top level package has moved from @alch/alchemy-sdk to alchemy-sdk for convenience. New command to install is npm install alchemy-sdk
  • Updated instantiation syntax: initializeAlchemy(settings) is now new Alchemy(settings)
  • Added three namespaces under the Alchemy object: core, nft, and ws. All Ethers.js provider methods and Alchemy Enhanced APIs (other than NFT) are under core.
  • Moved top-level methods under the Alchemy object. Instead of getNftsByOwner(alchemy, 'vitalik.eth'), now methods are called using alchemy.nft.getNftsByOwner('vitalik.eth')
  • Ethers.js Alchemy Provider methods are now directly embedded under alchemy.core
  • Ethers.js WebSocket Provider methods are now directly embedded under alchemy.ws
  • The settings object is now a config module under alchemy.config.
  • If necessary, the full Ethers.js Provider is now available under alchemy.config.getProvider() as a promise to reduce bundle size.
  • If necessary, the full WebSocket Provider is now available under alchemy.config.getWebSocketProvider() as a promise to reduce bundle size.
  • Dynamic imports for large methods (in particular, Ethers.js methods) are now supported. Initial package size for the Alchemy SDK is 20kB, and will only download Ethers.js packages when a relevant method is called.
  • Methods including Collection in the NFT package have been renamed to Contract: for instance, getNftsForCollection is now getNftsForContract.