新聞中心
將?Moralis?與?WalletConnect?集成
?WalletConnect??讓您可以通過二維碼、移動錢包和桌面錢包進行連接。?您可以在?WalletConnect?文檔中查看更多信息。

創(chuàng)新互聯(lián)建站主要從事做網(wǎng)站、成都網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)黃南州,十年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108
1.?添加?WalletConnect?提供商
根據(jù)moralis?導(dǎo)入項目的方式添加提供程序腳本?-??CDN?、?npm??或??yarn?。
npm install @walletconnect/web3-provideryarn add @walletconnect/web3-provider
確保檢查您是否使用最新的穩(wěn)定版本的??
WalletConnect?web3-provider?,并相應(yīng)地更新版本。?在?Github?上查看他們的最新版本
2.調(diào)用鑒權(quán)函數(shù)
調(diào)用身份驗證函數(shù),但帶有?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);
});
}
}
}3.指定chainId
指定??WalletConnect??默認(rèn)使用的鏈?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);
});
}
}
}4.過濾移動鏈接選項
要減少移動鏈接選項的數(shù)量或自定義其順序,請為??mobileLinks??選項提供一組?wallet names?,可以選擇使用?JS?或者?React?。
當(dāng)前文章:創(chuàng)新互聯(lián)Moralis教程:MoralisWalletConnect
分享鏈接:http://m.5511xx.com/article/cccjchg.html


咨詢
建站咨詢
