An example of visualizing Cardano transactions on the blockchain using AI via LLMs.
This project is an example of generating awesome images from the Cardano blockchain by sending details of a transaction to an AI LLM for returning an image.
Transaction details that are sent along in the prompt to the AI incude the transaction hash, sender wallet address, receiver wallet address, and amount of ADA. The resulting prompt is then used to generate an image through the LLM. The final step draws text on the image to show the transaction details.
We begin by loading the details for a specific transaction in the Cardano blockchain. This allows extracting the transaction id (hash), ADA amount sent, sender wallet address, and receiver wallet address. These values will be later when constructing the prompt for the LLM.
We'll also define a method for generating the prompt based upon the amount of ADA being sent in the transaction. Multiple bins separate balance amounts into differnt descriptions of imagery for the generated picture. For example, if a transaction is less than 5 ADA, the picture should only contain a small flower or a single tree. Whereas, if the transaction is greater than 100 ADA, the picture will include a dramatic and intense sunset.
The key to generating the picture with the LLM is in the construction of the prompt. Notice how details from the transaction are included within the prompt text.
prompt = f"Generate an image based on the following transaction details: \
Imagine a scene that represents the flow of value and connection between these entities. \
Include {objects} with {color_scheme}. \
Transaction ID: {tx_details.tx_id}, ADA Amount: {tx_details.ada_amount}, Sender: {tx_details.sender}, Receiver: {tx_details.receiver}."Images are generated by using the AI LLM from Hugging Face, specifically from Stable Diffusion. The prompt is sent to the Stable Diffusion model via the API. After receiving the image, the transaction details are drawn as text in the image to give a more realistic and financial spin to the final product.
The program is executed by asking the user to enter a transaction id from the Cardano blockchain. You can find a list of recent transactions here.
MIT
Kory Becker https://primaryobjects.com
