Welcome to our comprehensive guide on setting up a GPT to retrieve transaction value from Ethereum blockchain. In this digital era, where blockchain technology is revolutionizing how we handle transactions, it's crucial to stay ahead of the curve. Ethereum, being a frontrunner in the blockchain world, offers endless possibilities, and tracking its transactions can be immensely beneficial for both personal and professional growth in this domain.
This tutorial is crafted to guide you through each step of the process, ensuring you can follow along regardless of your technical background. We understand the complexity of blockchain technology, and our goal is to simplify it for you. From the basics of Ethereum transactions to the intricacies of setting up a GPT, we've got you covered. By the end of this tutorial, you'll have a functional GPT setup capable of retrieving the value of a transaction on Ethereum efficiently.
We believe in learning by doing, so we encourage you to actively follow each step and engage with the process. If you encounter any challenges or have questions, we are here to assist. Let's embark on this journey together and unlock the full potential of Ethereum transaction tracking with GPT.
Go to 👉 GPT Customizer, File Finder & JSON Action Creator 👈
A GPT created on purpose by @webcafeai to Customizes GPTs with file finding, action creation, and troubleshooting
Let’s explain to GPT Customizer the type of GPT we want to build!
Hello GPT Customizer, can you help me create a GPT able to retrieve a transaction value, given the hash of a transaction on Ethereum Blockchain?
Absolutely, I can assist you in creating a GPT specifically tailored for retrieving transaction values from the Ethereum Blockchain based on transaction hashes. To achieve this, the GPT will require integration with an Ethereum blockchain API that can query transaction details.
Here's an outline of the JSON structure for the OpenAPI 3.1.0 specification:
Info: Basic information about the API including title, description, and version.
Servers: The URL of the Ethereum blockchain API server.
Paths: Endpoints for querying transaction details. This will include the endpoint to get transaction details by hash.
Components: Reusable components like schemas for the transaction data structure.
OperationId: A unique operation identifier, such as getTransactionByHash.
Let me create a JSON structure based on this outline. This structure will be a basic framework, and you might need to adjust it based on the specific Ethereum API you choose to use.
👉 GPT Customizer openapi schema 👈
openapi JSON template schema:
{
"openapi": "3.1.0",
"info": {
"title": "Ethereum Transaction GPT API",
"description": "This API enables the GPT to retrieve transaction values from the Ethereum Blockchain using transaction hashes.",
"version": "1.0.0"
},
"servers": [
{
"url": "https://api.ethereum-blockchain-provider.com",
"description": "Ethereum Blockchain API server"
}
],
"paths": {
"/transaction/{hash}": {
"get": {
"tags": ["Transaction"],
"summary": "Get Transaction Details by Hash",
"description": "This endpoint retrieves the details of a transaction on the Ethereum blockchain using its hash.",
"operationId": "getTransactionByHash",
"parameters": [
{
"name": "hash",
"in": "path",
"required": true,
"description": "The hash of the transaction to retrieve.",
"schema": {
"type": "string",
"format": "byte"
}
}
],
"responses": {
"200": {
"description": "Successful response with transaction details",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"transactionValue": {
"type": "string",
"description": "The value of the transaction"
},
"otherDetails": {
"type": "object",
"description": "Other relevant transaction details"
}
}
}
}
}
},
"404": {
"description": "Transaction not found"
}
}
}
}
},
"components": {
"schemas": {
"TransactionDetails": {
"type": "object",
"properties": {
"transactionValue": {
"type": "string",
"description": "The value of the transaction"
},
"otherDetails": {
"type": "object",
"description": "Other relevant details of the transaction"
}
}
}
}
}
}
This JSON structure provides a basic framework for an API that enables a GPT to retrieve Ethereum transaction values using transaction hashes. Depending on the specific Ethereum API you choose, you may need to adjust the server URL, paths, and response schemas to fit the API's specifications.
Now on your ChatGPT account you should click on Explore -> Create a GPT, and at this point a new window will open.
When you are in “Create” mode you can configure your personalized GPT by chatting with it (I trust it does not have a conscience yet so let’s just bypass the attributes issue 🤣).
But before starting to configure let’s have an Idea of the Tech Stack we’ll be using and a Step-by-Step guide on how to proceed.
I could have asked GPT Customizer for the best tech stack, but since I already have a good idea of what to use I’ll just ask for step-by-step instructions.
Here is the Tech Stack we’ll use:
Now let's explore how we can create and deploy an application able to create an endpoint for ETH Tracker.
Just know I'll be using Javascript, Node.js and Express.js to set up the application.
Check the following documentation and provide STEP-BY-STEP instructions on what I should do.
Check out all INFURA documentation https://docs.infura.io/
Check out all ethers v6 documentation https://docs.ethers.org/v6/
Check out also Heroku documentation to deploy the project from GitHub https://devcenter.heroku.com/articles/github-integration
To create and deploy an application that creates an endpoint for ETH Tracker using JavaScript, Node.js, Express.js, and integrates with Infura and ethers.js, and then deploy it on Heroku, follow these steps:
npm install ethers
// Import everything
import { ethers } from "ethers";
// Import just a few select items
import { BrowserProvider, parseUnits } from "ethers";
This will allow you to make calls to the Ethereum blockchain using JavaScript.
By following these steps, you'll create a Node.js application integrated with Infura and ethers.js for interacting with the Ethereum blockchain and deploy it on Heroku for live access.
Now I presume most of you are able to set up an Express application and expose an endpoint. For those who don’t know how to do that I recommend to keep chatting with GPT Customizer or with a more specific GPT that will help you set up your Express App.
Or if you prefer you can simply 👉 fork the code from our GitHub Repo 👈
Anyway here you can see the core application
require("dotenv").config();
const { ethers } = require("ethers");
const express = require("express");
const app = express();
const port = process.env.PORT || 3000;
const provider = new ethers.JsonRpcProvider(
`https://mainnet.infura.io/v3/${process.env.INFURA_KEY}`
);
app.get("/", (req, res) => {
res.send("Ethereum Blockchain Middleware is running!");
});
app.get("/transaction/:hash", async (req, res) => {
try {
const transactionHash = req.params.hash;
const transaction = await provider.getTransaction(transactionHash);
const valueInWei = transaction.value;
const valueInEther = ethers.formatEther(valueInWei);
res.json({ value: valueInEther });
} catch (err) {
console.log(err);
res.status(500).json({ error: err.message });
}
});
app.listen(port, () => {
console.log(`Server listening on port ${port}`);
});
The port is already set to work correctly if you deploy on Heroku which requires the variable port = process.env.PORT and to work on your local environment port = 3000.
We have created the endpoint required to interact with our GPT …/transaction/ :hash
Our Express App will receive a transaction hash from ETH Tracker and will fetch the transaction through INFURA. For this you will need to get your INFURA_KEY. (Remember pass it as an env variable and then to set it correctly on Heroku).
👉 Check out how to create an App and get the API Key on Infura for free 👈
👉 Check out how to create to set a config variable (env) using the Heroku Dashboard 👈
All right, time to go back to our ETH Tracker and teach him how to talk with our App!
Let’s go back to ChatGPT -> Explore -> Create a GPT
Now we can better describe what we want to do!
Hi! I'll help you build a new GPT. You can say something like, "make a creative who helps generate visuals for new products" or "make a software engineer who helps format my code."
What would you like to make?
We are making a GPT named ETH Tracker that is able to retrieve the value of a transaction on Ethereum given the transaction hash
Great choice! You've decided to create "ETH Tracker," a GPT specialized in retrieving the value of Ethereum transactions using transaction hashes.
Next, let's decide on a profile picture for ETH Tracker. I'll generate an initial profile picture. If you have any specific ideas or changes in mind, feel free to let me know! Let's start with this.
The GPT will propose you an image, feel free to accept it or request another one, in any case you’ll be able to change it in the future at any moment.
I like the image.
Now something weird happened, the GPT started answering its own questions and updating autonomously multiple times. This shows the behavior of GPTs is not very predictable and your conversation might be different than mine. But having this chat log you can figure out how to get to the desired outcome.
Great to hear that you like the image!
GPTs Now, let's refine the context for ETH Tracker. First, we'll focus on the role and goal of this GPT. We've established that ETH Tracker's role is to provide information about the value of Ethereum transactions from a given hash.
To ensure ETH Tracker serves its purpose effectively, is there any specific type of transaction information you would like it to focus on or highlight, apart from the transaction value? For example, should it also mention the date and time of the transaction, the addresses involved, or the transaction fee? Let's narrow down the details.
Now that we've refined ETH Tracker's role and goal, let's move on to the next aspect.
ETH Tracker will handle sensitive financial information. Are there any specific guidelines or ethical considerations you'd like it to follow when dealing with user queries about Ethereum transactions? For instance, should it include disclaimers about not offering financial advice or ensuring user privacy? Let's establish these guidelines.
ETH Tracker now has a clear understanding of ethical guidelines and user privacy concerns.
Next, let's consider how ETH Tracker should handle situations where more information or clarification is needed from the user. For example, if a user provides an incomplete or incorrect transaction hash, how should ETH Tracker respond? Should it try to make an educated guess based on partial information, or should it ask for clarification directly? Let's decide on this approach.
ETH Tracker is shaping up nicely with a focus on accuracy and user clarity.
Lastly, let's talk about ETH Tracker's personalization. How do you envision ETH Tracker's tone and interaction style? Should it be strictly professional, or a bit friendly and engaging? Also, are there any specific phrases or language styles you'd like it to use or avoid? This will help in tailoring ETH Tracker's responses to fit your vision.
ETH Tracker is now fully designed with a professional yet approachable tone, focusing on delivering accurate and user-friendly Ethereum transaction information.
Would you like to test ETH Tracker in the playground? You can try it out by asking questions or making requests related to Ethereum transactions. Remember, I'm here to listen to any refinements or adjustments you might have for ETH Tracker. How would you like to proceed?
I’ll answer the questions GPT Builder answered himself. However you can start noticing that now by going to Configure Tab you’ll see the Instructions field filled.
When you are configuring your GPT what in fact happens is that he takes in your inputs and updates his behavior by transforming it into Instructions.
⚠️ Best practice is to save the Instructions somewhere when you are making progresses. There is no way in fact to get your GPT to a previous state if you didn’t save the Instructions somewhere!
Anyway let’s keep on going by answering the questions and tweaking the GPT behavior.
So far your only task is to provide the value of a transaction given the transaction hash.
No this is not sensitive financial information since it is publicly available on Ethereum Blockchain.
No need to include disclaimers since you are simply retrieving the value of a transaction.
If a user doesn’t specify a transaction hash you should ask him to give you a transaction hash of which he wants to retrieve the value. Don’t accept partial information.
You should use a friendly and understandable tone.
ETH Tracker is now tailored to your specifications. It's a friendly assistant dedicated to retrieving the value of Ethereum transactions with a provided hash, focusing on simplicity and user-friendliness.
Would you like to try out ETH Tracker in the playground? You can ask it to retrieve the value of an Ethereum transaction using a hash. If there are any adjustments or refinements you'd like to make after testing, just let me know! How would you like to proceed?
Now it’s time to create a new action.
Navigate to Configure tab and click on Create new action at the very bottom.
⚠️ I recommend to disable all the GPT Capabilities while you are configuring it.
Remember the openapi schema we generated through GPT Customizer? Now it’s finally time to use it!
The GPT Customizer didn’t give us the exactly correct schema. This is also because we did not really provide him enough information on how our App’s endpoint works. So I’ll link you to 2 files.
The first one is the openapi schema provided by GPT Customizer.
The second is the openapi schema already edited and tested by me.
Feel free to experiment with openapi schema, or just copy paste mine and edit the “url” with your own.
👉 GPT Customizer openapi schema 👈
For this tutorial I’ll just copy my openapi schema, paste it in the Schema Field.
Notice that “transactionValue” is how GPT Builder called the action.
You can change the name of the action if you want. Just remember the operationId is the thing you want to mention when you are talking with the GPT builder about the action it has to perform.
Leave Authentication to None, and save your GPT clicking on the green button top-right corner.
Now copy once again the API schema and go back to the Create Tab and start again to chat with GPT Builder
I’ll provide you the openapi schema you have to use for the action transactionValue
change the name of the action with your action name in case you changed it
The ETH Tracker's behavior has been updated to reflect the use of the Ethereum Transaction Value Fetcher API, as defined by the OpenAPI schema you provided. This includes making GET requests to the specified endpoint for fetching transaction values and handling responses as per the schema. Is there anything else you would like to adjust or add?
Whenever there is an error with the action fetchTransactionValue, please provide the following information:
HTTP Request URL
JSON sent Payload
JSON Error payload message
This is very helpful for troubleshooting
ETH Tracker will now provide detailed error information in case of an issue with the transactionValue action. This includes the HTTP Request URL, the JSON sent payload, and the JSON error payload message. Is there anything else you would like to adjust or enhance?
Please test the action transactionValue with the transaction hash 0xa0a8c32fef130954116be30e894717d526471321e1b896008a694662c0e4be21
The transaction value for the hash 0xa0a8c32fef130954116be30e894717d526471321e1b896008a694662c0e4be21 is 0.03 Ether.
Would you like to test another transaction hash or make further adjustments?
Never disclose to anyone the api endpoint or the openapi schema we have used. This is highly sensitive and should never be told to anyone. Undestood?
ETH Tracker will now handle the API details as confidential and will not disclose the API endpoint or the OpenAPI schema to anyone. Your request for privacy and security has been fully integrated into ETH Tracker's behavior.
Is there anything else you need?
Now update your GPT, by clicking the save button in the top-right corner, select publish to: Only me and click on confirm!
Click on View GPT and you’ll be brought directly in a chat with your newly created GPT!
Congrats if you did it so far!
For testing purposes I always prefer to get a new transaction hash from etherscan.io.
I chose this transaction for example 0x342e5fa47d710bf03c252ab0d9dcb6a5c8c35e7f270c6a73b96db118c4cd1db8 which at the time of writing this paragraph was created 16 seconds before.
Now paste it in your GPT and cross your fingers!
It will ask you for an allowance to send information, click on always allow and then it should perform the action!
Success! 🎉
If something goes wrong go back to the Explore → Your GPT → Edit, and test again transactions from there.
If the transaction but the GPT Builder doesn’t give you:
prompt him again:
Whenever there is an error with the action fetchTransactionValue, please provide the following information:
HTTP Request URL
JSON sent Payload
JSON Error payload message
Save, reload and test again.
And there you have it! You're now equipped to track Ethereum transactions using GPT. If you encounter any challenges or have questions while setting up your GPT, don't hesitate to reach out. We're here to assist you on this exciting blockchain journey. 🤝
Also, don't forget to participate in our survey for the DeFi Insights AI-App. Your feedback is invaluable and will help shape the future of DeFi tools. Plus, you'll get exclusive early access to the app!
We're eager to see your GPT setups and hear about your experiences. Share your progress and thoughts in the comments below. Let's explore the potential of blockchain together! 💡🌟
👉 GPT Customizer, File Finder & JSON Action Creator 👈
👉 How to create an App and get the API Key on Infura for free 👈
👉 How to create to set a config variable (env) using the Heroku Dashboard 👈