新聞中心
這里有您想知道的互聯(lián)網營銷解決方案
創(chuàng)新互聯(lián)Moralis教程:MoralisWalletConnect
將?Moralis?與?WalletConnect?集成
?WalletConnect??讓您可以通過二維碼、移動錢包和桌面錢包進行連接。?您可以在?WalletConnect?文檔中查看更多信息。

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


咨詢
建站咨詢
