Hook - useChainWallet
-
required provider: ChainProvider from either
@cosmos-kit/reactor@cosmos-kit/react-lite -
parameters:
- chainName:
ChainName( =string); - walletName:
WalletName( =string); - sync:
boolean=true
- chainName:
parameter
syncmeans whether to synchronize connection and disconnection to all other activated chainWallets.
- return type: ChainWalletContext
Type - ChainWalletContext
Properties
| Name | Description | Type | Default |
|---|---|---|---|
| chain | chain registry information | Chain | - |
| assets | chain assets information | AssetList | undefined | undefined |
| wallet | current selected wallet registry information | Wallet | undefined | undefined |
| logoUrl | chain logo url | string | undefined | undefined |
| address | chain address from current selected wallet | string | undefined | undefined |
| username | username from current selected wallet | string | undefined | undefined |
| message | error/warn/info message | string | undefined | undefined |
| status | wallet status | WalletStatus | Disconnected |
| isWalletDisconnected | if status === 'Disconnected' | boolean | true |
| isWalletConnecting | if status === 'Connecting' | boolean | false |
| isWalletConnected | if status === 'Connected' | boolean | false |
| isWalletRejected | if status === 'Rejected' | boolean | false |
| isWalletNotExist | if status === 'NotExist' | boolean | false |
| isWalletError | if status === 'Error' | boolean | false |
Methods
| Name | Description | Parameters | Return Type | Is Async |
|---|---|---|---|---|
| connect | connect wallet | wallet?: WalletName | void | Y |
| disconnect | disconnect current selected wallet | - | void | Y |
| getRpcEndpoint | return rpc endpoint, isLazy explanation is here | isLazy?: boolean | string | ExtendedHttpEndpoint | Y |
| getRestEndpoint | return rest endpoint, isLazy explanation is here | isLazy?: boolean | string | ExtendedHttpEndpoint | Y |
| getStargateClient | - | - | StargateClient | Y |
| getCosmWasmClient | - | - | CosmWasmClient | Y |
| getSigningStargateClient | always validate endpoint in method | - | SigningStargateClient | Y |
| getSigningCosmWasmClient | always validate endpoint in method | - | SigningCosmWasmClient | Y |
| getNameService | get name service object supported on provided chain | - | NameService | Y |
| estimateFee | if type is undefined, default using SigningStargateClient | messages: EncodeObject[],type?: CosmosClientType,memo?: string,multiplier?: number | StdFee | Y |
| sign | using cosmjs. if type is undefined, default using SigningStargateClient | messages: EncodeObject[],fee?: StdFee,memo?: string,type?: CosmosClientType | TxRaw | Y |
| broadcast | if type is undefined, default using SigningStargateClient | signedMessages: TxRaw,type?: CosmosClientType, | DeliverTxResponse | Y |
| signAndBroadcast | if type is undefined, default using SigningStargateClient | messages: EncodeObject[],fee?: StdFee,memo?: string,type?: CosmosClientType, | DeliverTxResponse | Y |
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
chainIdassigned aschainIdcorresponding to hook argumentchainName. If you want to directly use wallet client methods, choose hookuseWalletClientinstead.
| Name | Description | Parameters | Return Type | Is Async |
|---|---|---|---|---|
| setDefaultSignOptions | - | options: SignOptions | void | N |
| enable | - | - | void | Y |
| getAccount | - | - | WalletAccount | Y |
| getOfflineSigner | prioritize returning preferredSignType (in ChainProvider properties, by default amino) corresponding signer if it is available, otherwise return signer that is provided. | Y | ||
| getOfflineSignerAmino | - | - | OfflineAminoSigner | N |
| getOfflineSignerDirect | - | - | OfflineDirectSigner | N |
| signAmino | - | signer: string,signDoc: StdSignDoc,signOptions?: SignOptions | AminoSignResponse | Y |
| signDirect | - | signer: string,signDoc: StdSignDoc,signOptions?: SignOptions | DirectSignResponse | Y |
| signArbitrary | - | signer: string,data: string | Uint8Array | StdSignature | Y |
| sendTx | - | tx: Uint8Array,mode: BroadcastMode | Uint8Array | Y |
Advanced
Used for deeper dive into the chain and wallet related objects
| Name | Description | Type | Default |
|---|---|---|---|
| chainWallet | current chainWallet | ChainWalletBase | undefined | undefined |