Ask or search…
K
Links

Connect a wallet

Connecting to a MetaMask wallet means establishing a link between a decentralized application (dApp) or a web-based service and your MetaMask wallet. MetaMask is a browser extension that acts as a cryptocurrency wallet and a gateway to blockchain-based applications on the Ethereum network.
When you connect to a MetaMask wallet, you're granting the dApp or web service permission to access your wallet's address and interact with the Ethereum blockchain on your behalf. This may include actions such as signing transactions, sending tokens, or participating in decentralised finance (DeFi) protocols. This connection enables seamless interaction between users and blockchain applications while keeping private keys secure within the wallet.
MetaMask is designed as a browser extension to provide a user-friendly interface and secure key management for interacting with dApps and web services. Connecting from Node.js is not supported because MetaMask focuses on end-user interactions within web browsers, while Node.js is a server-side JavaScript runtime typically used for backend development.

How to get connect to MetaMask from your browser-based application

Use the TatumSDK (@tatumio/tatum) to check if there is a MetaMask extension available and get the default address from it.
You will leverage the WalletProvider submodule, which includes multiple browser-based wallet extensions. MetaMask is just one of them.
TypeScript
JavaScript
1
// yarn add @tatumio/tatum
2
import {TatumSDK, Network, Ethereum, MetaMask} from '@tatumio/tatum'
3
4
const tatum = await TatumSDK.init<Ethereum>({network: Network.ETHEREUM})
5
6
const metamaskAccount: string = await tatum.walletProvider.use(MetaMask).getWallet();
7
8
console.log(metamaskAccount)
1
// Install with: npm install @tatumio/tatum
2
const { TatumSDK, Network, MetaMask } = require("@tatumio/tatum");
3
4
(async () => {
5
try {
6
const tatum = await TatumSDK.init({ network: Network.ETHEREUM });
7
const metamaskAccount = await tatum.walletProvider.use(MetaMask).getWallet();
8
console.log(metamaskAccount);
9
} catch (error) {
10
console.error("Error fetching default account from MetaMask:", error);
11
}
12
})();
Expected Response
0xF64E82131BE01618487Da5142fc9d289cbb60E9d
© Tatum Technology, LLC