This is the WalletConnect package for NEAR Wallet Selector.
The easiest way to use this package is to install it from the NPM registry, this package requires near-api-js
v1.0.0 or above:
# Using Yarn
yarn add near-api-js
# Using NPM.
npm install near-api-js
# Using Yarn
yarn add @near-wallet-selector/wallet-connect
# Using NPM.
npm install @near-wallet-selector/wallet-connect
Then use it in your dApp:
import { setupWalletSelector } from "@meer-wallet-selector/core";
import { setupWalletConnect } from "@meer-wallet-selector/wallet-connect";
const walletConnect = setupWalletConnect({
projectId: "c4f79cc...",
metadata: {
name: "NEAR Wallet Selector",
description: "Example dApp used by NEAR Wallet Selector",
url: "https://github.com/mikedotexe/mallet-selector",
icons: ["https://avatars.githubusercontent.com/u/37784886"],
},
chainId: "near:testnet",
iconUrl: "https://<Wallet Icon URL Here>",
// Please note that the 'methods' option is discretionary;
// if omitted, all methods are included by default.
// Use it solely to override the default configuration.
methods: [
"near_signIn",
"near_signOut",
"near_getAccounts",
"near_signTransaction",
"near_signTransactions",
"near_verifyOwner",
"near_signMessage",
]
});
const selector = await setupWalletSelector({
network: "testnet",
modules: [walletConnect],
});
Project ID is required for wallet connect, please obtain it from walletconnect.com
-
projectId
(string
): Project ID isrequired
to instantiate the client. More details can be found here. -
metadata
(object
): Metadata used to provide context of the dApp to the connected wallet. More details can be found here. -
chainId
(string?
): Chain ID for requests. Defaults to"near:<networkId>
unless using custom network configuration. -
relayUrl
(string?
): Relay URL for requests. Defaults to"wss://relay.walletconnect.com"
. -
iconUrl
(string?
): Image URL for the icon shown in the modal. This can also be a relative path or base64 encoded image. Defaults to./assets/wallet-connect-icon.png
. -
deprecated
: (boolean?
): Deprecated is optional. Default isfalse
. -
methods
: (Array<string>?
): Methods is optional overrides default WC_METHODS. Defaults toundefined
. -
events
: (Array<string>?
): Events is optional overrides default WC_EVENTS. Defaults toundefined
.
near_signIn
near_signOut
near_getAccounts
near_signTransaction
near_signTransactions
near_verifyOwner
near_signMessage
chainChanged
accountsChanged
Assets such as icons can be found in the /assets
directory of the package. Below is an example using Webpack:
import { setupWalletConnect } from "@meer-wallet-selector/wallet-connect";
import walletConnectIconUrl from "@meer-wallet-selector/wallet-connect/assets/wallet-connect-icon.png";
const walletConnect = setupWalletConnect({
iconUrl: walletConnectIconUrl
});
This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0).