import { Fastlane, Wallet, Agent } from
'@fastlane-foundation/sdk';
async function start() {
const fastlane = new Fastlane('API_KEY');
const wallet = await Wallet.fromPrivateKey('PRIVATE_KEY');
const agent = await fastlane.connectToAgent('fastchat',
{ wallet });
// Define a callback for receiving messages from the agent
agent.on('message', (message) => {
console.log('Received message from the agent:', message);
});
agent.emit('sendMessage', { content: 'Hello, Fastchat!' });
}
start().catch(console.error);
import { Fastlane, Wallet, Agent } from
'@fastlane-foundation/sdk';
async function start() {
const fastlane = new Fastlane('API_KEY');
const wallet = await Wallet.fromPrivateKey('PRIVATE_KEY');
const agent = await fastlane.connectToAgent('fastchat',
{ wallet });
// Define a callback for receiving messages from the agent
agent.on('message', (message) => {
console.log('Received message from the agent:', message);
});
agent.emit('sendMessage', { content: 'Hello, Fastchat!' });
}
start().catch(console.error);
from fastlane_sdk import Fastlane, Wallet # Import Fastlane SDK
async def start():
# Initialize Fastlane with the developer's API key
fastlane = Fastlane('API_KEY')
# Create or load a wallet for transaction signing
wallet = await Wallet.from_private_key('PRIVATE_KEY')
agent = await fastlane.connect('fastchat', wallet=wallet)
print(f'Connected to agent: {agent.id}')
# Define a callback for receiving messages from the agent
@agent.on('message')
def handle_message(message):
print('Received message from the agent:', message)
# Send a message to the agent
message_to_send = {'content': 'Hello, Fastchat!'}
await agent.emit('sendMessage', message_to_send)
print('Message sent to the agent:', message_to_send)
import asyncio
asyncio.run(start())