Fraxgent

Description

Fraxgent is a powerful tool designed to interact with Fraxtal network, following the concept of the PostWeb by Outlier Ventures. It leverages OpenAI's GPT-4o-mini model to provide a conversational interface for users to perform various blockchain operations, such as checking wallet balances, sending transactions, deploying smart contracts, and more.

Features

  • Conversational Interface: Engage with the assistant to perform blockchain operations through natural language.
  • Wallet Operations: Check wallet balances and retrieve connected wallet addresses.
  • Transaction Management: Send transactions with customizable parameters.
  • Smart Contract Interaction: Deploy ERC20 tokens and interact with existing contracts.
  • API calls: Using Frax Finance APIs, you can ask for many data from the platform.
  • Error Handling: Robust error handling and feedback for failed operations.

Getting Started

Prerequisites

  • Node.js (version 14 or higher)
  • TypeScript
  • OpenAI API key with credits
  • Environment variables for wallet private key and other configurations

Installation

  1. Clone the repository:
   git clone https://github.com/techgethr/fraxgent.git
   cd fraxgent
  1. Install dependencies:
   bun install
  1. Set up environment variables: Create a .env file (or clone the .env.example from environment folder) in the root directory and add your OpenAI API key and Wallet private key: plaintext OPENAI_API_KEY=your_openai_api_key WALLET_PRIVATE_KEY=your_wallet_private_key

Usage

To start the assistant, run:

bun run src/index.ts

You can then interact with the assistant in the command line. Type "exit" to end the conversation.

Tools

The assistant has access to various tools for performing blockchain operations:

Read Operations

  • get_balance: Check wallet balances on the Fraxtal network
  • get_wallet_address: Retrieve the connected wallet's address
  • get_circulatingsupply: Retrieve the circulating supply for a specific token in Frax (FPI|FPIS|FRAX|FXS|frxETH|sfrxETH)
  • get_totalsupply: Retrieve the total supply for a specific token in Frax (FPI|FPIS|FRAX|FXS|frxETH|sfrxETH)
  • get_pricefortoken: Retrieve the price (in USD) for a specific token in Frax (FPI|FPIS|FRAX|FXS|frxETH|sfrxETH)
  • get_tokensavailablefraxswap: Retrieve the tokens available in FraxSwap to make transactions
  • get_availablepools: Retrieve the available staking pools in Frax Finance

Write Operations

  • send_transaction: Send transactions with customizable parameters including:
    • Transaction value in frxETH
    • Custom data for contract interactions
    • Gas price settings
    • EIP-2930 access lists
    • Factory dependencies
    • Paymaster configurations
  • deploy_erc20: Deploy new ERC20 token contracts with:
    • Customizable token name and symbol
    • Configurable initial supply
    • Standard ERC20 functionality

Codebase Flow

  1. Initialization:

    • Application starts with creating an OpenAI Assistant
    • A new Thread is created for the conversation
  2. Chat Session Loop:

    • User enters commands through the CLI
    • Commands are processed through the Thread and Assistant
    • For blockchain operations, specific Tools are called
    • Results are returned through the chain of components
  3. Blockchain Integration:

    • Tools interface with the blockchain through Viem clients
    • Operations are executed on the Fraxtal network.
    • Results are propagated back to the user
  4. Session Management:

    • Users can exit the application at any time
    • Each command is processed in a sequential manner
    • Responses are displayed back to the user

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

  • Viem for blockchain interaction utilities.
  • OpenAI for providing the GPT-4o-mini model.

Contact

https://x.com/nes_campos https://github.com/nescampos

Built With

Share this project:

Updates