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:
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.