Docs

Discover how Phala's AI Agent Contract offers the essential tools to develop and profit from intelligent applications.

Explore Now

Pond Use Case: Token Prediction Agent

Invalid Date

Overview

Connecting onchain applications to specialized AI models can take a lot of effort, and performing this action in a secure way is difficult in Web3 today. With Phala’s latest partnership with Pond, we close that gap and provide a solution for developers to build on today. Phala has created an AI Agent Contract template to provide a seamless connection to Pond’s powerful Graph Neural Network (GNN) model giving developers direct access to token price predictions on ETH and BASE.

Pond

Pond is building a decentralized Graph Neural Network (GNN) model for Web 3.0. This model is designed to learn on-chain behaviors and predict future behaviors. Developed by leading data scientists and machine learning researchers, our model is the first of its kind and will support crypto-native use cases such as on-chain trading, leveraging on-chain liquidity, social networking, security, and more.

By harnessing the inherent structure of data and delivering enriched and denser information, Pond's model facilitates more informed decision-making and driving innovation across various sectors in crypto.

Pond Integration

By leveraging Pond’s Graph Neural Network model, Phala users will have access to precise on-chain behaviors and predictions for their trading research, enabling the development of advanced and AI-powered trading strategies. With only one line of code, developers can interact with Pond’s API to fetch Pond’s WBTC price predictions.

const response = await fetch(
	'http://model-v2-api-471546444.us-east-1.elb.amazonaws.com:8001/api/v1/predict/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599'
);

Build a Token Prediction AI Agent

A project recently built a Token Prediction Agent that allowed users to query a token’s price prediction through a Chat interface. The code uses a call to RedPill’s API to retrieve the token’s ETH address in the correct format then appends that token address to the Pond API request URL to get the price prediction of the token

const response = await fetch('https://api.red-pill.ai/v1/chat/completions', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer <API-KEY>`
    },
    body: JSON.stringify({
        messages: [{ role: "user", content: `Give ${tokenSymbol}'s token symbol and address on ethereum mainnet! list it in this format {\"symbol\":string, \"address\":string}. don't print anything else` }],
        model: `${openAiModel}`,
    })
});
const responseData = await response.json();
result = responseData.choices[0].message.content as string;
let token = JSON.parse(result);
const tokenAddress = token.address

const pondBaseUrl = "http://model-v2-api-471546444.us-east-1.elb.amazonaws.com:8001/api/v1/predict";
let fullPondUrl = `${pondBaseUrl}/${tokenAddress}`;

const pondResult = await fetch(fullPondUrl);
let pondPredictions = await pondResult.json();

Here is a look at what the user interface looked like when the user submits /prediction WBTC in their chat prompt.

Conclusion

Pond’s GNN model does not stop at a simple interface for users to ask for token predictions. With the ability to implement additional logic in their AI Agent Contract, developers can start building out autonomous onchain trading agents, develop advanced yield strategies, and much more.

For more detailed information and to start building:

About Phala

Phala Network is a decentralized cloud that offers secure and scalable computing for Web3.

With Phat Contracts, an innovative programming model enabling trustless off-chain computation, developers can create new Web3 use cases.

Get the latest Phala Content Straight To Your Inbox.