@@ -17,6 +17,7 @@ import (
1717 "github.com/nathfavour/settlerengine/internal/adapters/crypto/mantle"
1818 "github.com/nathfavour/settlerengine/internal/domain"
1919 "github.com/nathfavour/settlerengine/pkg/anyisland"
20+ "github.com/nathfavour/settlerengine/pkg/config"
2021 "github.com/nathfavour/settlerengine/pkg/crypto"
2122 "github.com/nathfavour/settlerengine/pkg/storage"
2223 "github.com/nathfavour/settlerengine/pkg/uds"
@@ -46,6 +47,8 @@ func main() {
4647 runPay (os .Args [2 :])
4748 case "demo" :
4849 runDemo (os .Args [2 :])
50+ case "config" :
51+ runConfig (os .Args [2 :])
4952 case "help" :
5053 printUsage ()
5154 default :
@@ -64,27 +67,72 @@ func printUsage() {
6467 fmt .Println (" facilitator Start the settlement facilitator daemon" )
6568 fmt .Println (" pay Execute a policy-protected payment" )
6669 fmt .Println (" demo Run a full agentic demo with Mantle on-chain anchoring" )
70+ fmt .Println (" config Interactively configure SettlerEngine" )
6771 fmt .Println (" help Show this help message" )
6872}
6973
74+ func runConfig (args []string ) {
75+ cfg , err := config .LoadConfig ()
76+ if err != nil {
77+ // Default config if none exists
78+ cfg = & config.SettlerConfig {
79+ RPCURL : "https://rpc.sepolia.mantle.xyz" ,
80+ RegistryAddress : "0x33aE8331a2406EEc3A33483001aC5650DA2e0662" ,
81+ AgentID : "42" ,
82+ }
83+ }
84+
85+ cfg .Prompt ()
86+
87+ if err := config .SaveConfig (cfg ); err != nil {
88+ log .Fatalf ("❌ Failed to save config: %v" , err )
89+ }
90+
91+ path , _ := config .GetConfigPath ()
92+ fmt .Printf ("✅ Configuration saved to: %s\n " , path )
93+ }
94+
7095func runDemo (args []string ) {
7196 fmt .Println ("🎬 Starting SettlerEngine Agentic Demo..." )
7297
98+ cfg , _ := config .LoadConfig ()
99+ if cfg == nil {
100+ cfg = & config.SettlerConfig {}
101+ }
102+
73103 privKey := os .Getenv ("PRIVATE_KEY" )
74104 if privKey == "" {
75- log .Fatal ("❌ PRIVATE_KEY environment variable is required for demo" )
105+ privKey = cfg .PrivateKey
106+ }
107+ if privKey == "" {
108+ log .Fatal ("❌ PRIVATE_KEY required (set env or run 'settler config')" )
109+ }
110+
111+ rpcURL := cfg .RPCURL
112+ if rpcURL == "" {
113+ rpcURL = "https://rpc.sepolia.mantle.xyz"
114+ }
115+
116+ registryAddr := cfg .RegistryAddress
117+ if registryAddr == "" {
118+ registryAddr = "0x33aE8331a2406EEc3A33483001aC5650DA2e0662"
119+ }
120+
121+ agentIDStr := cfg .AgentID
122+ if agentIDStr == "" {
123+ agentIDStr = "42"
76124 }
125+ agentID , _ := new (big.Int ).SetString (agentIDStr , 10 )
77126
78127 // 1. ERC-8004 Identity Resolution
79128 fmt .Println ("🤖 [1/3] Resolving Agent Identity (ERC-8004)..." )
80129 registry , _ := erc8004 .NewRegistryClient (
81- "https://rpc.sepolia.mantle.xyz" ,
130+ rpcURL ,
82131 common .HexToAddress ("0x8004000000000000000000000000000000000001" ),
83132 common .HexToAddress ("0x8004000000000000000000000000000000000002" ),
84133 common .HexToAddress ("0x8004000000000000000000000000000000000003" ),
85134 )
86135
87- agentID := big .NewInt (42 )
88136 identity , _ := registry .ResolveAgent (context .Background (), agentID )
89137 fmt .Printf ("✅ Identity Verified: %s\n " , identity .Metadata .Name )
90138
@@ -104,8 +152,8 @@ func runDemo(args []string) {
104152 // 3. Mantle On-Chain Anchoring
105153 fmt .Println ("⚓ [3/3] Anchoring transaction to Mantle Sepolia..." )
106154 mantleClient , err := mantle .NewRegistryClient (
107- "https://rpc.sepolia.mantle.xyz" ,
108- common .HexToAddress ("0x33aE8331a2406EEc3A33483001aC5650DA2e0662" ),
155+ rpcURL ,
156+ common .HexToAddress (registryAddr ),
109157 big .NewInt (5003 ),
110158 )
111159 if err != nil {
0 commit comments