Alchemy Quickstart Guide (2024)

πŸ‘‹ New to Alchemy? Get access to Alchemy for free here.

Estimated time to complete this guide: < 10 minutes

This guide assumes you already have an Alchemy account and access to our Dashboard.

1. πŸ”‘ Create an Alchemy API key

2. ✍️ Make a request

3. 🀝 Set up Alchemy as your client

4. πŸ’» Start building!

1.πŸ”‘ Create an Alchemy API Key

To use Alchemy's products, you need an API key to authenticate your requests.

You get an API key when you create an app from the dashboard. Follow the steps below to create an app:

  1. First, navigate to your Alchemy dashboard and click on the "Apps" tab.

    Alchemy Quickstart Guide (1)

  2. Next, click on the "Create new app" button.

    Alchemy Quickstart Guide (2)


  3. Fill in the details for your new app, this includes specifying a name and description (optional) for it. Then click the "Create app" button.

    Alchemy Quickstart Guide (3)


  4. Once your app is created, you will be redirected to the app details page, here you will see your API key in the top right corner.

    Alchemy Quickstart Guide (4)


  5. By default the API key is enabled for all the chains and networks, switch to the "Networks" tab to disable certain chains and view the request URLs.

    Alchemy Quickstart Guide (5)

  6. You can easily disable networks using the "Configure" option.

    Alchemy Quickstart Guide (6)

You can interact with Alchemy's infrastructure provider using JSON-RPC and your command line.

For manual requests, we recommend interacting with the JSON-RPC via POST requests. Simply pass in the Content-Type: application/json header and your query as the POST body with the following fields:

  • jsonrpc: The JSON-RPC versionβ€”currently, only 2.0 is supported.
  • method: The ETH API method. See API reference.
  • params: A list of parameters to pass to the method.
  • id: The ID of your request. Will be returned by the response so you can keep track of which request a response belongs to.

Here is an example you can run from the Terminal/Windows/LINUX command line to retrieve the current gas price:

curl https://eth-mainnet.g.alchemy.com/v2/demo \-X POST \-H "Content-Type: application/json" \-d '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":73}'

πŸ“˜

Please remember to replace "demo" in the request URL with your actual Alchemy API key you created in the last step!

Results:

{ "id": 73, "jsonrpc": "2.0", "result": "0x09184e72a000" // 10000000000000 }

Want to integrate Alchemy into your production app?

Find out how to set up or switch your current provider to Alchemy by using the Alchemy SDK, the easiest and most powerful way to access Alchemy's suite of Enhanced APIs and tools.

❗️

For existing clients:

If you have an existing client, change your current node provider URL to an Alchemy URL with your API key: "https://eth-mainnet.g.alchemy.com/v2/your-api-key"

Note: The scripts below need to be run in a node context or saved in a file, not run from the command line.

The Alchemy SDK

There are tons of Web3 libraries you can integrate with Alchemy. However, we recommend using the Alchemy SDK, a drop-in replacement for Ethers.js, built and configured to work seamlessly with Alchemy. This provides multiple advantages such as automatic retries and robust WebSocket support.

1. From your command line, create a new project directory and install the Alchemy SDK.

To install the Alchemy SDK, you want to create a project, and then navigate to your project directory to run the installation. Let's go ahead and do that! Once we're in our home directory, let's execute the following:

With Yarn:

mkdir your-project-namecd your-project-nameyarn init # (or yarn init --yes)yarn add alchemy-sdk

With NPM:

mkdir your-project-namecd your-project-namenpm init # (or npm init --yes)npm install alchemy-sdk

2. Create a file named index.js and add the following contents:

πŸ“˜

Hint

You should ultimately replace demo with your Alchemy HTTP API key.

// Setup: npm install alchemy-sdkconst { Network, Alchemy } = require("alchemy-sdk");// Optional Config object, but defaults to demo api-key and 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);async function main() { const latestBlock = await alchemy.core.getBlockNumber(); console.log("The latest block number is", latestBlock);}main();

Unfamiliar with the async stuff? Check out this Medium post.

3. Run it using node

node index.js

4. You should now see the latest block number output in your console!

The latest block number is 11043912

Woo! Congrats! You just wrote your first web3 script using Alchemy and sent your first request to your Alchemy API endpoint πŸŽ‰

The app associated with your API key should now look like this on the dashboard:

Alchemy Quickstart Guide (7)


Don't know where to start? Check out these four tutorials to get more familiar with Alchemy and blockchain development:

  1. Examples of Common Queries Using the Alchemy SDK
  2. Write a simple web3 script
  3. Learn How to Send Transactions on Ethereum
  4. Try deploying your first Hello World Smart Contract and get your hands dirty with some solidity programming!

Once you complete this tutorial, let us know how your experience was or if you have any feedback by tagging us on Twitter @alchemyplatform!

Other Web3 Libraries

Check out the documentation for each library:

Using the below code snippets, you can install and use Alchemy as a provider via any of the following libraries!

# Setup: pip install web3from web3 import Web3alchemy = Web3(Web3.HTTPProvider("https://eth-mainnet.g.alchemy.com/v2/your-api-key"));
// Setup: curl -L get.web3j.io | shWeb3j web3 = Web3j.build(new HttpService("https://eth-mainnet.g.alchemy.com/v2/your-api-key"));
// Setup: npm install ethersconst ethers = require("ethers");const url = "https://eth-mainnet.g.alchemy.com/v2/your-api-key";const customHttpProvider = new ethers.providers.JsonRpcProvider(url);
// Setup: npm install web3const Web3 = require('web3');const web3 = new Web3("https://eth-mainnet.g.alchemy.com/v2/your-api-key");

Updated 3 months ago

Alchemy Quickstart Guide (2024)
Top Articles
Basics of JWT and How to Decode JWT tokens in node?
Do Arcades Games Still Exist? | Arcades Australia
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & FahrrΓ€dern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Dmv In Anoka
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Umn Biology
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Weekly Math Review Q4 3
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
Selly Medaline
Latest Posts
Article information

Author: Lidia Grady

Last Updated:

Views: 6065

Rating: 4.4 / 5 (65 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Lidia Grady

Birthday: 1992-01-22

Address: Suite 493 356 Dale Fall, New Wanda, RI 52485

Phone: +29914464387516

Job: Customer Engineer

Hobby: Cryptography, Writing, Dowsing, Stand-up comedy, Calligraphy, Web surfing, Ghost hunting

Introduction: My name is Lidia Grady, I am a thankful, fine, glamorous, lucky, lively, pleasant, shiny person who loves writing and wants to share my knowledge and understanding with you.