Developers who are familiar with ethers
can install @ant-design/web3-ethers
to use with the component library, most of which are consistent with the wagmi
adapter.
npm install @ant-design/web3 @ant-design/web3-ethers ethers --save
This example shows basic usage using the ethers
adapter. We provide two react hooks to obtain provider
and signer
, which you can use in components to perform on-chain operations.
useEthersProvider
: Get the Provider
instance of ethers
.useEthersSigner
: Get the Signer
instance of ethers
.If you are a user of ethers@5.x
, you can manually install the v5 version of ethers and modify the adapter introduction method. Versions prior to v5 are no longer supported. It is recommended to use after upgrading to the latest version:
npm install @ant-design/web3 @ant-design/web3-ethers-v5 ethers@legacy-v5 --save
import { EthersWeb3ConfigProvider, useEthersProvider } from '@ant-design/web3-ethers-v5'; // importing the adapter for ethers@5.xconst Component = () => {const provider = useEthersProvider();// do something with provider};const App = () => {return (<EthersWeb3ConfigProvider><Component /></EthersWeb3ConfigProvider>);};
Property | Description | Type | Default | Version |
---|---|---|---|---|
wallets | Wallets | WalletFactory[] | - | - |
chains | Chains | Chain[] | - | - |
ens | Whether to display ENS | boolean | - | - |
balance | Whether to display balance | boolean | - | - |
locale | Multilingual settings | Locale | - | - |
eip6963 | Whether to use EIP6963 protocol wallet and related configurations | boolean | EIP6963Config | false | |
walletConnect | Whether to use the Wallet Connect protocol | false | WalletConnectOptions | false | |
storage | Persists config's state between sessions. | false | WagmiStorage | - | next |