getCapabilities
Gets wallet capabilities (EIP-5792)
This implements EIP-5792.
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() }()
capabilities, err := wallet.GetCapabilities(ctx, walletClient, wallet.GetCapabilitiesParameters{})if err != nil { log.Fatal(err)}log.Printf("Capabilities: %+v", capabilities)Get Capabilities for Specific Chain
Query capabilities for a specific chain ID.
chainID := int64(1) // Mainnetcapabilities, err := wallet.GetCapabilities(ctx, walletClient, wallet.GetCapabilitiesParameters{ ChainID: &chainID,})if err != nil { log.Fatal(err)}log.Printf("Mainnet capabilities: %+v", capabilities[chainID])Returns
ChainIDToCapabilities (map[int64]Capabilities)
A map where keys are chain IDs and values are capability objects for that chain. If ChainID is provided, the map will only contain capabilities for that specific chain.
Parameters
Account
Control which account address to use when resolving capabilities.
-
Type:
*string -
Optional
The account address to get capabilities for. If nil, uses the client's account.
accountAddr := "0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC"capabilities, err := wallet.GetCapabilities(ctx, walletClient, wallet.GetCapabilitiesParameters{ Account: &accountAddr,})ChainID
Restrict capabilities to a particular chain ID.
-
Type:
*int64 -
Optional
Optionally restricts capabilities to a specific chain. If set, returns capabilities only for this chain ID. If nil, returns capabilities for all chains.
chainID := int64(1) // Mainnetcapabilities, err := wallet.GetCapabilities(ctx, walletClient, wallet.GetCapabilitiesParameters{ ChainID: &chainID,})JSON-RPC Method
-
The underlying JSON-RPC method invoked by this action.
-
wallet_getCapabilities(EIP-5792)