### Install Safe Dependencies (bun) Source: https://wagmi.sh/react/api/connectors/safe Install the necessary Safe provider and SDK packages using bun. ```bash bun add @safe-global/safe-apps-provider@{{connectorDependencyVersions?.[0]}} @safe-global/safe-apps-sdk@{{connectorDependencyVersions?.[1]}} ``` -------------------------------- ### Install Wagmi v3 with bun Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the latest version of Wagmi using bun. ```bash bun add wagmi@3 ``` -------------------------------- ### Install Porto Connector Source: https://wagmi.sh/react/api/connectors/porto Install the Porto connector using your preferred package manager. ```bash-vue pnpm add porto@{{connectorDependencyVersion}} ``` ```bash-vue npm install porto@{{connectorDependencyVersion}} ``` ```bash-vue yarn add porto@{{connectorDependencyVersion}} ``` ```bash-vue bun add porto@{{connectorDependencyVersion}} ``` -------------------------------- ### Install Base Account SDK Source: https://wagmi.sh/react/api/connectors/baseAccount Install the Base Account SDK using your preferred package manager. ```bash-vue pnpm add @base-org/account@{{connectorDependencyVersion}} ``` ```bash-vue npm install @base-org/account@{{connectorDependencyVersion}} ``` ```bash-vue yarn add @base-org/account@{{connectorDependencyVersion}} ``` ```bash-vue bun add @base-org/account@{{connectorDependencyVersion}} ``` -------------------------------- ### Install Coinbase Wallet SDK Source: https://wagmi.sh/react/api/connectors/coinbaseWallet Install the Coinbase Wallet SDK using your preferred package manager. ```bash pnpm add @coinbase/wallet-sdk@{{connectorDependencyVersion}} ``` ```bash npm install @coinbase/wallet-sdk@{{connectorDependencyVersion}} ``` ```bash yarn add @coinbase/wallet-sdk@{{connectorDependencyVersion}} ``` ```bash bun add @coinbase/wallet-sdk@{{connectorDependencyVersion}} ``` -------------------------------- ### Install Safe Dependencies (npm) Source: https://wagmi.sh/react/api/connectors/safe Install the necessary Safe provider and SDK packages using npm. ```bash npm install @safe-global/safe-apps-provider@{{connectorDependencyVersions?.[0]}} @safe-global/safe-apps-sdk@{{connectorDependencyVersions?.[1]}} ``` -------------------------------- ### Install MetaMask Connect EVM Source: https://wagmi.sh/react/api/connectors/metaMask Install the necessary @metamask/connect-evm package using your preferred package manager. ```bash-vue pnpm add @metamask/connect-evm@{{connectorDependencyVersion}} ``` ```bash-vue npm install @metamask/connect-evm@{{connectorDependencyVersion}} ``` ```bash-vue yarn add @metamask/connect-evm@{{connectorDependencyVersion}} ``` ```bash-vue bun add @metamask/connect-evm@{{connectorDependencyVersion}} ``` -------------------------------- ### useReadContract Example Source: https://wagmi.sh/react/api/hooks/useReadContract An example demonstrating how to use the `useReadContract` hook to read the `balanceOf` function from a smart contract. It shows the necessary setup with `createConfig` and the hook's parameters. ```APIDOC ## useReadContract ### Description Reads data from a smart contract. ### Method `useReadContract` ### Parameters #### `abi` (object[]) - Required An array of contract Application Binary Interface (ABI) entries. #### `address` (address | `{ [chainId: number]: address }`) - Required The address of the contract. #### `functionName` (string) - Required The name of the function to call on the contract. #### `args` (any[]) - Optional Arguments to pass to the contract function. ### Request Example ```ts import { createConfig, http, useReadContract } from 'wagmi' import { mainnet, sepolia } from 'wagmi/chains' const config = createConfig({ chains: [mainnet, sepolia], transports: { [mainnet.id]: http(), [sepolia.id]: http(), }, }) const result = useReadContract({ abi: [ { type: 'function', name: 'balanceOf', stateMutability: 'view', inputs: [{ name: 'account', type: 'address' }], outputs: [{ type: 'uint256' }], }, { type: 'function', name: 'totalSupply', stateMutability: 'view', inputs: [], outputs: [{ type: 'uint256' }], }, ], address: '0x...', // Replace with the actual contract address functionName: 'balanceOf', args: ['0x...'], // Replace with the account address }) ``` ### Response #### Success Response The hook returns an object containing the contract data and status information. - **data** (T | undefined): The data returned from the contract function call. - **error** (TError | undefined): An error object if the call fails. - **isError** (boolean): True if the call resulted in an error. - **isLoading** (boolean): True if the call is in progress. - **isSuccess** (boolean): True if the call was successful. - **refetch** (Function): A function to manually refetch the data. ``` -------------------------------- ### Install Safe Dependencies (yarn) Source: https://wagmi.sh/react/api/connectors/safe Install the necessary Safe provider and SDK packages using yarn. ```bash yarn add @safe-global/safe-apps-provider@{{connectorDependencyVersions?.[0]}} @safe-global/safe-apps-sdk@{{connectorDependencyVersions?.[1]}} ``` -------------------------------- ### Install Safe Dependencies (pnpm) Source: https://wagmi.sh/react/api/connectors/safe Install the necessary Safe provider and SDK packages using pnpm. ```bash pnpm add @safe-global/safe-apps-provider@{{connectorDependencyVersions?.[0]}} @safe-global/safe-apps-sdk@{{connectorDependencyVersions?.[1]}} ``` -------------------------------- ### Install Accounts Package Source: https://wagmi.sh/react/api/connectors/tempoWallet Install the accounts package with the specified version using your preferred package manager. ```bash-vue pnpm add accounts@{{connectorDependencyVersion}} ``` ```bash-vue npm install accounts@{{connectorDependencyVersion}} ``` ```bash-vue yarn add accounts@{{connectorDependencyVersion}} ``` ```bash-vue bun add accounts@{{connectorDependencyVersion}} ``` -------------------------------- ### Install Wagmi v3 with yarn Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the latest version of Wagmi using yarn. ```bash yarn add wagmi@3 ``` -------------------------------- ### Install Wagmi v3 with npm Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the latest version of Wagmi using npm. ```bash npm install wagmi@3 ``` -------------------------------- ### Install porto dependency with bun Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the `porto` npm package required for the `porto` connector using bun. ```bash bun add porto@{{packageJson?.peerDependencies?.['porto']}} ``` -------------------------------- ### Install coinbaseWallet dependency with bun Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the `@coinbase/wallet-sdk` npm package required for the `coinbaseWallet` connector using bun. ```bash bun add @coinbase/wallet-sdk@{{packageJson?.peerDependencies?.['@coinbase/wallet-sdk']}} ``` -------------------------------- ### Install Wagmi v3 with pnpm Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the latest version of Wagmi using pnpm. ```bash pnpm add wagmi@3 ``` -------------------------------- ### Install WalletConnect Ethereum Provider Source: https://wagmi.sh/react/api/connectors/walletConnect Install the necessary WalletConnect Ethereum provider package using your preferred package manager. ```bash pnpm add @walletconnect/ethereum-provider@{{connectorDependencyVersion}} ``` ```bash npm install @walletconnect/ethereum-provider@{{connectorDependencyVersion}} ``` ```bash yarn add @walletconnect/ethereum-provider@{{connectorDependencyVersion}} ``` ```bash bun add @walletconnect/ethereum-provider@{{connectorDependencyVersion}} ``` -------------------------------- ### Install metaMask dependency with bun Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the `@metamask/connect-evm` npm package required for the `metaMask` connector using bun. ```bash bun add @metamask/connect-evm@{{packageJson?.peerDependencies?.['@metamask/connect-evm']}} ``` -------------------------------- ### Install metaMask dependency with npm Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the `@metamask/connect-evm` npm package required for the `metaMask` connector using npm. ```bash npm install @metamask/connect-evm@{{packageJson?.peerDependencies?.['@metamask/connect-evm']}} ``` -------------------------------- ### Install TanStack Query Persister Packages Source: https://wagmi.sh/react/guides/tanstack-query Install the necessary packages for TanStack Query persistence with sync storage. Choose the command corresponding to your package manager. ```bash pnpm i @tanstack/query-sync-storage-persister @tanstack/react-query-persist-client ``` ```bash npm i @tanstack/query-sync-storage-persister @tanstack/react-query-persist-client ``` ```bash yarn add @tanstack/query-sync-storage-persister @tanstack/react-query-persist-client ``` ```bash bun i @tanstack/query-sync-storage-persister @tanstack/react-query-persist-client ``` -------------------------------- ### Install Safe Apps Provider and SDK Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the necessary packages for Safe Apps integration using your preferred package manager. ```bash-vue pnpm add @safe-global/safe-apps-provider@{{packageJson?.peerDependencies?.['@safe-global/safe-apps-provider']}} @safe-global/safe-apps-sdk@{{packageJson?.peerDependencies?.['@safe-global/safe-apps-sdk']}} ``` ```bash-vue npm install @safe-global/safe-apps-provider@{{packageJson?.peerDependencies?.['@safe-global/safe-apps-provider']}} @safe-global/safe-apps-sdk@{{packageJson?.peerDependencies?.['@safe-global/safe-apps-sdk']}} ``` ```bash-vue yarn add @safe-global/safe-apps-provider@{{packageJson?.peerDependencies?.['@safe-global/safe-apps-provider']}} @safe-global/safe-apps-sdk@{{packageJson?.peerDependencies?.['@safe-global/safe-apps-sdk']}} ``` ```bash-vue bun add @safe-global/safe-apps-provider@{{packageJson?.peerDependencies?.['@safe-global/safe-apps-provider']}} @safe-global/safe-apps-sdk@{{packageJson?.peerDependencies?.['@safe-global/safe-apps-sdk']}} ``` -------------------------------- ### Install porto dependency with npm Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the `porto` npm package required for the `porto` connector using npm. ```bash npm install porto@{{packageJson?.peerDependencies?.['porto']}} ``` -------------------------------- ### Install coinbaseWallet dependency with npm Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the `@coinbase/wallet-sdk` npm package required for the `coinbaseWallet` connector using npm. ```bash npm install @coinbase/wallet-sdk@{{packageJson?.peerDependencies?.['@coinbase/wallet-sdk']}} ``` -------------------------------- ### Install baseAccount dependency with bun Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the `@base-org/account` npm package required for the `baseAccount` connector using bun. ```bash bun add @base-org/account@{{packageJson?.peerDependencies?.['@base-org/account']}} ``` -------------------------------- ### Install metaMask dependency with pnpm Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the `@metamask/connect-evm` npm package required for the `metaMask` connector using pnpm. ```bash pnpm add @metamask/connect-evm@{{packageJson?.peerDependencies?.['@metamask/connect-evm']}} ``` -------------------------------- ### Install Wagmi from Pull Request with bun Source: https://wagmi.sh/react/installation Install a Wagmi version from a specific pull request using bun. ```bash bun add https://pkg.pr.new/{{packageName}}@123 ``` -------------------------------- ### Install Wagmi canary version with bun Source: https://wagmi.sh/react/installation Install the latest canary version of Wagmi from the main branch using bun. ```bash bun add {{packageName}}@canary ``` -------------------------------- ### Install coinbaseWallet dependency with pnpm Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the `@coinbase/wallet-sdk` npm package required for the `coinbaseWallet` connector using pnpm. ```bash pnpm add @coinbase/wallet-sdk@{{packageJson?.peerDependencies?.['@coinbase/wallet-sdk']}} ``` -------------------------------- ### Install baseAccount dependency with npm Source: https://wagmi.sh/react/guides/migrate-from-v2-to-v3 Install the `@base-org/account` npm package required for the `baseAccount` connector using npm. ```bash npm install @base-org/account@{{packageJson?.peerDependencies?.['@base-org/account']}} ``` -------------------------------- ### Install Wagmi canary version with yarn Source: https://wagmi.sh/react/installation Install the latest canary version of Wagmi from the main branch using yarn. ```bash yarn add {{packageName}}@canary ``` -------------------------------- ### Basic Usage of useClient Hook Source: https://wagmi.sh/react/api/hooks/useClient Use the `useClient` hook within a React component to get the Viem Client instance. This example shows a basic setup without any parameters. ```tsx import { useClient } from 'wagmi' function App() { const client = useClient() } ``` ```typescript import { createConfig, http } from 'wagmi' import { mainnet, sepolia } from 'wagmi/chains' export const config = createConfig({ chains: [mainnet, sepolia], transports: { [mainnet.id]: http(), [sepolia.id]: http(), }, }) ``` -------------------------------- ### Basic useConnect Usage Source: https://wagmi.sh/react/api/hooks/useConnect Use the useConnect hook to get the connect function and trigger the connection process. This example shows how to initiate a connection with a specific connector. ```javascript import { useConnect } from 'wagmi' function Component() { const { connect, connectors, error, isLoading, pending } = useConnect({ // connector: injected, }) return (