
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
@meer-wallet-selector/ethereum-wallets
Advanced tools
Ethereum wallets package for NEAR Wallet Selector.
This is the Ethereum Wallets package for NEAR Wallet Selector. The package adds support for Ethereum wallets by creating Ethereum-compatible transactions from NEAR transaction inputs.
Ethereum wallet support NEP: https://github.com/near/NEPs/issues/518
Any Ethereum wallet can be connected via Web3Modal: the dApp can chose which wallets to support and a multichain dApp can switch networks using the same wallet connection.
SignIn requires switching to NEAR network to ensure that the wallet is compatible, if the user switches to other networks he will be prompted to switch back to NEAR before making a transaction.
Sign out prompts to remove the FunctionCall access key if there is one, this action is non blocking and the user can sign out without executing the transaction.
A NEAR dApp can connect to multiple Ethereum wallet addresses. If the user switches to a new address from the Ethereum wallet, the NEAR wallet will be disconnected so that it can reconnect with the signIn flow. If the dApp doesn't require a FunctionCall access key or the Ethereum wallet address already signed in, then the address connects automatically when changed.
NEP-518 doesn't support multiple actions within the same transaction, so when multiple actions are requested, they are split into separate transactions and executed 1 by 1.
NEP-518 rpc relayer uses a FunctionCall access key to execute transactions on behalf of the user by calling rlp_execute
. If this key is not yet added, the wallet will be onboarded before the first transaction is made.
signMessage
and verifyOwner
are not implemented because Ethereum wallets are not compatible with these standards, instead a dApp can use personal_sign
or eth_signTypedData_v4
to authenticate the wallet by interacting with it directly.
# Using Yarn
yarn add near-api-js @web3modal/wagmi wagmi viem @tanstack/react-query @near-wallet-selector/ethereum-wallets
# Using NPM.
npm install near-api-js @web3modal/wagmi wagmi viem @tanstack/react-query @near-wallet-selector/ethereum-wallets
Then use it in your dApp:
Visit https://docs.walletconnect.com for the latest configuration of Web3Modal.
import type { Config } from "@wagmi/core";
import { reconnect, http, createConfig } from "@wagmi/core";
import { walletConnect, injected } from "@wagmi/connectors";
import { setupWalletSelector } from "@meer-wallet-selector/core";
import { setupEthereumWallets } from "@meer-wallet-selector/ethereum-wallets";
const wagmiConfig: Config = createConfig({
chains: [near],
transports: {
[near.id]: http(),
},
connectors: [
walletConnect({ projectId, metadata, showQrModal: false }),
injected({ shimDisconnect: true }),
],
});
reconnect(wagmiConfig);
const web3Modal = createWeb3Modal({
wagmiConfig: config,
// Get a project ID at https://cloud.walletconnect.com
projectId,
});
const _selector = await setupWalletSelector({
network: "mainnet",
debug: true,
modules: [
setupEthereumWallets({ wagmiConfig, web3Modal }),
],
});
Project ID is required, please obtain it from walletconnect.com
wagmiConfig
: Wagmi Config for interacting with Ethereum wallets.web3Modal
(Web3Modal?
): Web3Modal object for connecting an Ethereum wallet. If not provided this module will connect to the default injected wallet (MetaMask browser extension, embedded browser wallets...).chainId
(number?
): Chain ID of the NEAR web3 rpc to connect to. Defaults to 397
(mainnet
) or 398
(testnet
) depending on the setupWalletSelector
network configuration.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/ethereum-wallets-icon.png
.wagmiCore
(typeof import("@wagmi/core")?
): Optional, @wagmi/core functions can be overidden by the dapp to interract with the wallet.alwaysOnboardDuringSignIn
(boolean?
): A dapp without SignIn access key will not onboard the relayer by default, this option does the relayer onboarding during login.nearNodeUrl
(string?
): NEAR node url to query the NEAR transaction status and onboarding access key.Developent options (before the NEAR protocol upgrade to support 0x accounts natively):
devMode
(boolean?
): During development NEAR protocol doesn't yet support 0x123...abc
accounts natively so in devMode the account with format 0x123...abc.eth-wallet.testnet
is used insead. Setup your devMode account at https://near-wallet-playground.testnet.aurora.devdevModeAccount
(string?
): Modify the namespace of the devMode root accounts.Dapps can connect to Ethereum wallets directly (using w3m-button
for example) by watching the connected Ethereum account and connecting to the ethereum-wallets
module automatically without opening the NEAR modal.
import { watchAccount } from "@wagmi/core";
useEffect(() => {
if (!selector) {
return
}
watchAccount(wagmiConfig, {
onChange: (data) => {
if (!data.address || selector.store.getState().selectedWalletId) {
return
}
selector.wallet("ethereum-wallets").then((wallet) =>
wallet.signIn({
contractId: CONTRACT_ID,
})
)
},
})
}, [selector])
Web3Modal and Log in with Ethereum flows are the preferred UX for connecting to any Ethereum wallet. But this module is also available to use without Web3Modal: it will connect to the default injected wallet (Metamask browser extension, embedded browser wallets...).
This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
FAQs
Ethereum wallets package for NEAR Wallet Selector.
We found that @meer-wallet-selector/ethereum-wallets demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.