getAddresses
Returns a list of addresses owned by the wallet or client
If the client has a local account attached (implements LocalAccount), it returns the local address directly without making an RPC call.
Import
Import the wallet actions package so you can call this action.
import "github.com/ChefBingbong/viem-go/actions/wallet"Usage
See how to construct a wallet client and call this action.
import ( "context" "log"
"github.com/ChefBingbong/viem-go/actions/wallet" "github.com/ChefBingbong/viem-go/client" "github.com/ChefBingbong/viem-go/client/transport" "github.com/ChefBingbong/viem-go/chain/definitions")
ctx := context.Background()
walletClient, err := client.CreateWalletClient(client.WalletClientConfig{ Chain: definitions.Mainnet, Transport: transport.HTTP("https://eth.llamarpc.com"),})if err != nil { log.Fatal(err)}defer func() { _ = walletClient.Close() }()
addresses, err := wallet.GetAddresses(ctx, walletClient)if err != nil { log.Fatal(err)}log.Printf("Addresses: %v", addresses)Returns
[]address.Address
A list of checksummed Ethereum addresses.
Parameters
This action takes no parameters.
JSON-RPC Method
-
The underlying JSON-RPC method invoked by this action.
Note: For local accounts, this action returns the local address directly without making an RPC call.