Cosmos Kit
Hooks
- useChainWallet

Hook - useChainWallet

  • required provider: ChainProvider from either @cosmos-kit/react or @cosmos-kit/react-lite

  • parameters:

    • chainName: ChainName ( = string );
    • walletName: WalletName ( = string );
    • sync: boolean = true

parameter sync means whether to synchronize connection and disconnection to all other activated chainWallets.

Type - ChainWalletContext

Properties

NameDescriptionTypeDefault
chainchain registry informationChain-
assetschain assets informationAssetList | undefinedundefined
walletcurrent selected wallet registry informationWallet | undefinedundefined
logoUrlchain logo urlstring | undefinedundefined
addresschain address from current selected walletstring | undefinedundefined
usernameusername from current selected walletstring | undefinedundefined
messageerror/warn/info messagestring | undefinedundefined
statuswallet statusWalletStatusDisconnected
isWalletDisconnectedif status === 'Disconnected'booleantrue
isWalletConnectingif status === 'Connecting'booleanfalse
isWalletConnectedif status === 'Connected'booleanfalse
isWalletRejectedif status === 'Rejected'booleanfalse
isWalletNotExistif status === 'NotExist'booleanfalse
isWalletErrorif status === 'Error'booleanfalse

Methods

NameDescriptionParametersReturn TypeIs Async
connectconnect walletwallet?: WalletNamevoidY
disconnectdisconnect current selected wallet-voidY
getRpcEndpointreturn rpc endpoint, isLazy explanation is hereisLazy?: booleanstring | ExtendedHttpEndpointY
getRestEndpointreturn rest endpoint, isLazy explanation is hereisLazy?: booleanstring | ExtendedHttpEndpointY
getStargateClient--StargateClientY
getCosmWasmClient--CosmWasmClientY
getSigningStargateClientalways validate endpoint in method-SigningStargateClientY
getSigningCosmWasmClientalways validate endpoint in method-SigningCosmWasmClientY
getNameServiceget name service object supported on provided chain-NameServiceY
estimateFeeif type is undefined, default using SigningStargateClientmessages: EncodeObject[],
type?: CosmosClientType,
memo?: string,
multiplier?: number
StdFeeY
signusing cosmjs. if type is undefined, default using SigningStargateClientmessages: EncodeObject[],
fee?: StdFee,
memo?: string,
type?: CosmosClientType
TxRawY
broadcastif type is undefined, default using SigningStargateClientsignedMessages: TxRaw,
type?: CosmosClientType,
DeliverTxResponseY
signAndBroadcastif type is undefined, default using SigningStargateClientmessages: EncodeObject[],
fee?: StdFee,
memo?: string,
type?: CosmosClientType,
DeliverTxResponseY

Properties from Wallet Client

| Name | Description | Type | Default | | ---------------------- | ----------- | ------------------ | ---------- | ----------- | | qrUrl | - | Mutable\<string\> | undefined | undefined | | appUrl | - | Mutable\<AppUrl\> | undefined | undefined | | defaultSignOptions | - | SignOptions | as below |

defaultSignOptions:

{
    preferNoSetFee: false,
    preferNoSetMemo: true,
    disableBalanceCheck: true,
  };

Methods from Wallet Client

These methods are equal to wallet client methods with argument chainId assigned as chainId corresponding to hook argument chainName. If you want to directly use wallet client methods, choose hook useWalletClient instead.

NameDescriptionParametersReturn TypeIs Async
setDefaultSignOptions-options: SignOptionsvoidN
enable--voidY
getAccount--WalletAccountY
getOfflineSignerprioritize returning preferredSignType (in ChainProvider properties, by default amino) corresponding signer if it is available, otherwise return signer that is provided.Y
getOfflineSignerAmino--OfflineAminoSignerN
getOfflineSignerDirect--OfflineDirectSignerN
signAmino-signer: string,
signDoc: StdSignDoc,
signOptions?: SignOptions
AminoSignResponseY
signDirect-signer: string,
signDoc: StdSignDoc,
signOptions?: SignOptions
DirectSignResponseY
signArbitrary-signer: string,
data: string | Uint8Array
StdSignatureY
sendTx-tx: Uint8Array,
mode: BroadcastMode
Uint8ArrayY

Advanced

Used for deeper dive into the chain and wallet related objects

NameDescriptionTypeDefault
chainWalletcurrent chainWalletChainWalletBase | undefinedundefined

Examples

fetch address (opens in a new tab)

governance (opens in a new tab)