-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.go
More file actions
33 lines (27 loc) · 787 Bytes
/
setup.go
File metadata and controls
33 lines (27 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package blockrun
import (
"context"
"fmt"
)
// SetupAgentWallet creates or loads a wallet and returns a configured LLMClient.
// If the wallet is new, prints funding instructions.
func SetupAgentWallet(opts ...ClientOption) (*LLMClient, error) {
wallet, err := GetOrCreateWallet()
if err != nil {
return nil, fmt.Errorf("failed to setup wallet: %w", err)
}
client, err := NewLLMClient(wallet.PrivateKey, opts...)
if err != nil {
return nil, err
}
if wallet.IsNew {
fmt.Print(FormatWalletCreatedMessage(wallet.Address))
}
return client, nil
}
// Status returns wallet address and USDC balance.
func (c *LLMClient) Status(ctx context.Context) (address string, balance float64, err error) {
address = c.GetWalletAddress()
balance, err = c.GetBalance(ctx)
return
}