Underlying Code Examples

Let's examine some sample code for

import requests

# MIND API Endpoint
API_URL = "https://api.greaterthan.com/deploy"

# Agent Configuration
agent_config = {
    "name": "ArbitrageAgent",
    "network": "Solana",
    "parameters": {
        "min_profit": 0.08,  # Minimum profit percentage
        "max_gas_fee": 0.01,  # Maximum gas fee in Gwei
        "target_pairs": ["SOL/USDC", "SOL/USDT"],  # Trading pairs
    },
    "auth_key": "your_authorization_key_here"
}

def deploy_agent(config):
    try:
        response = requests.post(API_URL, json=config)
        if response.status_code == 200:
            print("Agent deployed successfully!")
            print("Agent ID:", response.json()["agent_id"])
        else:
            print("Deployment failed:", response.json()["error"])
    except Exception as e:
        print("Error:", str(e))

# Deploy the agent
deploy_agent(agent_config)

Rust Example: Deploying a Mining Agent

This example shows how to deploy a Proof-of-Work (PoW) SynthMining agent using Rust and WebAssembly.

use reqwest::blocking::Client;
use serde_json::json;

fn main() {
    let client = Client::new();
    let api_url = "https://api.greaterthan.com/deploy";

    // Agent Configuration
    let agent_config = json!({
        "name": "MiningAgent",
        "network": "Bitcoin",
        "parameters": {
            "hash_rate": 1000,  // Hash rate in H/s
            "min_payout": 0.001,  // Minimum payout threshold in BTC
        },
        "auth_key": "your_authorization_key_here"
    });

    // Send the deployment request
    let response = client.post(api_url)
        .json(&agent_config)
        .send();

    match response {
        Ok(resp) if resp.status().is_success() => {
            let body: serde_json::Value = resp.json().unwrap();
            println!("Agent deployed successfully!");
            println!("Agent ID: {}", body["agent_id"]);
        },
        Ok(resp) => {
            println!("Deployment failed: {}", resp.text().unwrap());
        },
        Err(e) => {
            println!("Error: {}", e);
        }
    }
}

How These Examples Work

  1. Python: Uses the requests library to send a POST request with the agent’s configuration to GREATERthan’s deployment API.

  2. Rust: Utilizes reqwest for HTTP requests and serde_json to format the agent’s parameters. The Rust implementation ensures low-latency execution and enterprise-grade reliability.

Both examples can be customized for your use case by modifying parameters like network, profit thresholds, or hash rate. Replace "your_authorization_key_here" with your actual API key provided by GREATERthan.

With these simple code snippets, developers can quickly understand how to interact with GREATERthan’s powerful infrastructure to deploy and manage their agents.

Last updated