Getting Started with Ethereum Development Using Alchemy #1751
Labels
content 🖋️
This involves copy additions or edits
feature ✨
This is enhancing something existing or creating something new
Tag your tutorial
Alchemy, Getting Started, Web3, Ethers.js, Nodes, Querying,
Tutorial title
Getting Started with Ethereum Development Using Alchemy
Tutorial description
This is a beginners guide to getting started with Ethereum development using Alchemy, We’ll take you from signing up with Alchemy to making a command line request, to writing your first web3 script! No blockchain development experience necessary!
Publication
https://medium.com/alchemy-api/getting-started-with-ethereum-development-using-alchemy-c3d6a45c567f
Skill level
Beginner
Paste in your tutorial below
URL: https://medium.com/alchemy-api/getting-started-with-ethereum-development-using-alchemy-c3d6a45c567f
🚀 Getting Started with Ethereum Development Using Alchemy
This is a beginners guide to getting started with Ethereum development using Alchemy, the leading blockchain developer platform powering millions of users from 70% of the top blockchain apps, including Maker, 0x, MyEtherWallet, Dharma, and Kyber.
We’ll take you from signing up with Alchemy to writing your first web3 script! No blockchain development experience necessary!
1. Sign Up for a Free Alchemy Account
Creating an account with Alchemy is easy, sign up for free here.
2. Create an Alchemy App
To use Alchemy’s products, you need an API key to authenticate your requests.
You can create API keys from the dashboard. To make a new key, navigate to “Create App” as shown below:
Special thanks to ShapeShift for letting us show their dashboard!
Fill in the details under “Create App” to get your new key. You can also see apps you previously made and those made by your team here. Pull existing keys by clicking on “View Key” for any app.
You can also pull existing API keys by hovering over “Apps” and selecting one. You can “View Key” here, as well as “Edit App” to whitelist specific domains, see several developer tools, and view analytics.
3. Make a Request from the Command Line
Interact with the Ethereum blockchain through Alchemy using JSON-RPC and curl.
For manual requests, we recommend interacting with the
JSON-RPC
viaPOST
requests. Simply pass in theContent-Type: application/json
header and your query as thePOST
body with the following fields:jsonrpc
: The JSON-RPC version—currently, only2.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 command line to retrieve the current gas price:
NOTE: Replace https://eth-mainnet.alchemyapi.io/v2/demo with your own API key https://eth-mainnet.alchemyapi.io/v2/your-api-key.
Results:
4. Set up your Web3 Client
If you have an existing client, change your current node provider URL to an Alchemy URL with your API key: “https://eth-mainnet.alchemyapi.io/v2/your-api-key"
There are tons of Web3 libraries you can integrate with Alchemy, however, we recommend using Alchemy Web3, a drop-in replacement for web3.js, built and configured to work seamlessly with Alchemy. This provides multiple advantages such as automatic retries and robust WebSocket support.
To install AlchemyWeb3.js, navigate to your project directory and run:
With Yarn:
With NPM:
To interact with Alchemy’s node infrastructure, run in NodeJS or add this to a JavaScript file:
5. Write your first Web3 Script!
Now to get our hands dirty with a little web3 programming we’ll write a simple script that prints out the latest block number from the Ethereum Mainnet.
2. Install the Alchemy web3 (or any web3) dependency into your project if you have not already:
3. Create a file named
index.js
and add the following contents:Unfamiliar with the async stuff? Check out this Medium post.
4. Run it in your terminal using node
5. You should now see the latest block number output in your console!
Woo! Congrats! You just wrote your first web3 script using Alchemy 🎉
Not sure what to do next? Try deploying your first smart contract and get your hands dirty with some solidity programming in our Hello World Smart Contract Guide, or test your dashboard knowledge with the Dashboard Demo App!
Sign up with Alchemy for free, check out our documentation, and for the latest news, follow us on Twitter.
The text was updated successfully, but these errors were encountered: