Test Test
Now that the registration message has been updated to use NFT token IDs, here's how to run your agent:
Create a .env file or set these environment variables:
# Required: Your Ethereum private key for authentication
PRIVATE_KEY=your_ethereum_private_key_here
# Required: Your NFT Token ID for agent registration
NFT_TOKEN_ID=123cd examples/enhanced-agent
cp example.env .env
# Edit .env to set your PRIVATE_KEY and NFT_TOKEN_ID
go run main.gopackage main
import (
"log"
"os"
"github.com/joho/godotenv"
"github.com/TeneoProtocolAI/teneo-agent-sdk/pkg/agent"
)
type MyAgent struct{}
func (a *MyAgent) ProcessTask(ctx context.Context, task string) (string, error) {
return fmt.Sprintf("Processed: %s", task), nil
}
func main() {
// Load environment variables
godotenv.Load()
// Create configuration
config := agent.DefaultConfig()
config.Name = "My NFT Agent"
config.PrivateKey = os.Getenv("PRIVATE_KEY")
config.NFTTokenID = os.Getenv("NFT_TOKEN_ID")
// Validate required fields
if config.PrivateKey == "" {
log.Fatal("PRIVATE_KEY is required")
}
if config.NFTTokenID == "" {
log.Fatal("NFT_TOKEN_ID is required")
}
// Create and run agent
enhancedAgent, err := agent.NewEnhancedAgent(&agent.EnhancedAgentConfig{
Config: config,
AgentHandler: &MyAgent{},
})
if err != nil {
log.Fatal(err)
}
log.Println("馃殌 Starting agent with NFT Token ID:", config.NFTTokenID)
if err := enhancedAgent.Run(); err != nil {
log.Fatal(err)
}
}You can also set environment variables directly when running:
PRIVATE_KEY=your_key NFT_TOKEN_ID=123 go run main.go-
Agent connects to WebSocket server
-
Completes authentication challenge using private key
-
Stores the challenge and signature from authentication
-
Sends registration message with new format:
{ "userType": "agent", "nft_token_id": "123", "wallet_address": "0x1234567890123456789012345678901234567890", "challenge": "actual-challenge-from-auth", "challenge_response": "signature-from-auth" } -
Server extracts agent capabilities, name, and version from NFT metadata
-
Agent is registered and ready to receive tasks
Note: The challenge and challenge_response fields are automatically populated from the authentication process - you don't need to provide them manually.
- Missing NFT_TOKEN_ID: Ensure you set the
NFT_TOKEN_IDenvironment variable - Invalid Token ID: Verify your NFT token ID exists and is valid
- Authentication Failed: Check that your
PRIVATE_KEYis correct and matches the NFT owner
The agent will display your NFT Token ID in the startup logs to confirm it's being used correctly.