Skip to content

getAlchemyRpcUrlById

Retrieves the complete Alchemy RPC URL for a given chain ID.

Usage

import { getAlchemyRpcUrlById } from '@ethereum-tag-service/contracts/utils'
 
const url = getAlchemyRpcUrlById('84532', 'your-api-key')
// @log: Output: "https://base-sepolia.g.alchemy.com/v2/your-api-key"
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2307. Expected: // @errors: 2307 Compiler Errors: index.ts [2307] 37 - Cannot find module '@ethereum-tag-service/contracts/utils' or its corresponding type declarations.

Returns

string

A string representing the complete Alchemy RPC URL with API key.

Parameters

chainId

  • Type: SupportedChainId
  • Description: The ID of the chain

alchemyKey

  • Type: string
  • Description: The Alchemy API key to append to the URL

Examples

import { getAlchemyRpcUrlById } from '@ethereum-tag-service/contracts/utils'
 
// Get complete Arbitrum Sepolia RPC URL
const baseUrl = getAlchemyRpcUrlById('84532', 'YOUR_API_KEY')
// @log: Output: https://base-sepolia.g.alchemy.com/v2/YOUR_API_KEY
 
// Get complete Base Sepolia RPC URL
const baseUrl = getAlchemyRpcUrlById('84532', 'YOUR_API_KEY')
// @log: Output: https://base-sepolia.g.alchemy.com/v2/YOUR_API_KEY
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2307 2451. Expected: // @errors: 2307 2451 Compiler Errors: index.ts [2307] 37 - Cannot find module '@ethereum-tag-service/contracts/utils' or its corresponding type declarations. [2451] 125 - Cannot redeclare block-scoped variable 'baseUrl'. [2451] 293 - Cannot redeclare block-scoped variable 'baseUrl'.