WalletConnect 让您可以通过二维码、移动钱包和桌面钱包进行连接。 您可以在 WalletConnect 文档中查看更多信息。

创新互联建站主要从事做网站、成都网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务黄南州,十年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108
根据moralis 导入项目的方式添加提供程序脚本 - CDN、npm 或 yarn。
npm install @walletconnect/web3-provideryarn add @walletconnect/web3-provider
确保检查您是否使用最新的稳定版本的
WalletConnect web3-provider,并相应地更新版本。 在 Github 上查看他们的最新版本
调用身份验证函数,但带有provider选项,可以选择使用JS或者React:
const user = await Moralis.authenticate({ provider: "walletconnect" })import { useMoralis } from "react-moralis";
function App() {
const { authenticate, isAuthenticated, user } = useMoralis();
const login = async () => {
if (!isAuthenticated) {
await authenticate({ provider: "walletconnect" })
.then(function (user) {
console.log(user!.get("ethAddress"));
})
.catch(function (error) {
console.log(error);
});
}
}
}指定 WalletConnect 默认使用的链 ID。 您可以通过提供 chainId 作为额外选项来做到这一点,可以选择使用JS或者React:
const user = await Moralis.authenticate({ provider: "walletconnect", chainId: 56 })import { useMoralis } from "react-moralis";
function App() {
const { authenticate, isAuthenticated, user } = useMoralis();
const login = async () => {
if (!isAuthenticated) {
await authenticate({ provider: "walletconnect", chainId: 56 })
.then(function (user) {
console.log(user!.get("ethAddress"));
})
.catch(function (error) {
console.log(error);
});
}
}
}要减少移动链接选项的数量或自定义其顺序,请为 mobileLinks 选项提供一组wallet names,可以选择使用JS或者React。