Join our
Discord!
LogoLogo
SupraScan ExplorerStarKey WalletDiscord
  • Network
  • Oracles
  • Automation
  • SupraNova
  • AI Agents
  • Your First AI Agent on Supra
Powered by GitBook

Links

  • Whitepapers
  • Bug Bounty
  • Security Audits

‎

  • Supra Dev Hub
  • Supra Labs Github
  • Entropy Foundation Github
On this page
  • Why Choose Supra for AI Agents?
  • Prerequisites
  • Project Setup
  • Interacting with the Agent
  • Conclusion

Your First AI Agent on Supra

Last updated 23 hours ago

In this guide, you’ll learn how to build and run your first Supra AI Agent, an interactive agent that communicates with the Supra Network and capable of:

  • Fetching your account balance and on‑chain information

  • Funding your account via faucet

  • Retrieving transaction details by transaction hash

  • Retrieving your transaction history

  • Fetching any on‑chain resource data

Why Choose Supra for AI Agents?

Supra’s vertically integrated infrastructure, plus tight coupling of at its core, creates the most complete environment for AI Agents to flourish in a multi-chain DeFi world.

With real-time data through Supra’s built-in Oracles, native automation, cross-chain communication, and seamless execution all in one stack, Supra will allow your AI Agent to operate at peak intelligence and speed. Supra is the first platform where strategy becomes execution without friction.

In a world of fragmented tools, Supra delivers the one thing AI Agents truly need: a unified infrastructure to execute your intent at the speed of light.

Prerequisites

Before getting started, make sure you have the following installed:

  • Node.js

  • npm installed

Project Setup

1

Clone This Repo

git clone https://github.com/Supra-Labs/Supra-agents-hub.git
2

Navigate into Agents sub-dir & Open Target Agent Directory.

cd Agents
cd "SupraOnChainAgent"
3

Install Dependencies

npm install
4

Running Your Agent

npx ts-node agent.ts

You should see a welcome message with your generated account address and list of available commands. Sample Output below:

$ npx ts-node agent.ts

*** Welcome to SupraOnChainAgent ***

Initializing Supra Client...
Connected to network with chain ID: _ChainId { value: 6 }
Loaded existing account from account.json
Your Supra Account Address: 0x26b58df6a3716bc16de96d6aa5fa60c1cf12e0854e8983b4a6d0a4a9548c218d

Available commands:
 - 'what is the balance of my account'     : Fetch account info & balance
 - 'please fund my account'                 : Fund account via faucet
 - 'show me transaction details for <TX_HASH>': Fetch transaction details
 - 'what is my transaction history'         : Retrieve transaction history
 - 'show my account resources'              : Fetch resource data
 - 'help'                                   : Show this help message
 - 'exit'                                   : Quit the agent

SupraOnChainAgent>

The agent will carry out the corresponding blockchain operations using the Supra-L1-SDK.

Interacting with the Agent

1

Wallet Creation

$ npx ts-node agent.ts

*** Welcome to SupraOnChainAgent ***

Initializing Supra Client...
Connected to network with chain ID: _ChainId { value: 8 }
Loaded existing account from account.json
Your Supra Account Address: 0x26b58df6a3716bc16de96d6aa5fa60c1cf12e0854e8983b4a6d0a4a9548c218d
2

Fetching the Wallet Balance

Make sure you fund your wallet via Faucet else it won't be showing registered on chain.

Supra OnChain Agent> what is the balance of my account

--- Account Info ---
Address          : 0x26b58df6a3716bc16de96d6aa5fa60c1cf12e0854e8983b4a6d0a4a9548c218d
Sequence Number  : 0n
Authentication Key: 0x26b58df6a3716bc16de96d6aa5fa60c1cf12e0854e8983b4a6d0a4a9548c218d
Balance          : 1000000000
---------------------
3

Funding Wallet.

Supra OnChain Agent> please fund my account
Requesting funds via faucet...
Faucet Response: {
  status: 'Success',
  transactionHash: '0x866984a1ae3b3225379b0aa77f83f25a169faef6c605d22da8df8c51ab196a0f'
}
Updated Account Balance: 1500000000
4

Transaction History of an account.

Supra OnChain Agent> what is my transaction history

--- Transaction History ---

// Your History

---------------------------
5

Fetching Transaction details based on its TXN Hash.

Supra OnChain Agent> show me transaction details for 0x0eddc65189edae437e326908f9039f046801eec8db8a08e5b01b0a75b7dfd46a

--- Transaction Details ---
{
  "txHash": "0x0eddc65189edae437e326908f9039f046801eec8db8a08e5b01b0a75b7dfd46a",
  "sender": "0x6f12b0fe05ba8796c0455981c88c99a11539ef205723a1740fc7dd72cb98520f",
  "sequenceNumber": 1553378,
  "maxGasAmount": 500000,
  "gasUnitPrice": 100,
  "gasUsed": 35,
  "transactionCost": 3500,
  "txExpirationTimestamp": 1747814148000000,
  "txConfirmationTime": 1747813849978867,
  "status": "Success",
  "events": [
    {
      "guid": {
        "creation_number": "0",
        "account_address": "0x0"
      },
      "sequence_number": "0",
      "type": "0x1::coin::CoinWithdraw",
      "data": {
        "account": "0x6f12b0fe05ba8796c0455981c88c99a11539ef205723a1740fc7dd72cb98520f",
        "amount": "518227",
        "coin_type": "0x8ede5b689d5ac487c3ee48ceabe28ae061be74071c86ffe523b7f42acda2fcb7::test_usdc::TestUSDC"
      }
    }
6

Looking for Resources in your account

Supra OnChain Agent> show my account resources

--- Account Resources ---
{
  "resource": [
    [
      "0x0000000000000000000000000000000000000000000000000000000000000001::account::Account",
      {
        "address": "0000000000000000000000000000000000000000000000000000000000000001",
        "module": "account",
        "name": "Account",
        "type_args": []
      }
    ],
    [
      "0x0000000000000000000000000000000000000000000000000000000000000001::coin::CoinStore<0000000000000000000000000000000000000000000000000000000000000001::supra_coin::SupraCoin>",
      {
        "address": "0000000000000000000000000000000000000000000000000000000000000001",
        "module": "coin",
        "name": "CoinStore",
        "type_args": [
          {
            "struct": {
              "address": "0000000000000000000000000000000000000000000000000000000000000001",
              "module": "supra_coin",
              "name": "SupraCoin",
              "type_args": []
            }
          }
        ]
      }
    ]
  ],
  "cursor": "0026b58df6a3716bc16de96d6aa5fa60c1cf12e0854e8983b4a6d0a4a9548c218d6801000000000000000000000000000000000000000000000000000000000000000104636f696e09436f696e53746f7265010700000000000000000000000000000000000000000000000000000000000000010a73757072615f636f696e095375707261436f696e0000"
}
-------------------------

Conclusion

Congratulations on building your first Supra Agent! This guide serves as a starting point in your journey into the Supra ecosystem.

OpenBlocks.ai