PolkaGate
  • Introduction
    • ๐Ÿ Welcome to PolkaGate
    • ๐Ÿ•Š๏ธPolkaGate Extension
    • ๐Ÿ›นPolkaGate MetaMask Snap
  • POLKAGATE Extension User Guide
    • ๐Ÿ”งInstalling PolkaGate Extension
    • CREATE ACCOUNT
      • โž•Create New Account
      • ๐ŸŒฑDerive from Accounts
    • IMPORT ACCOUNT
      • ๐Ÿ—„๏ธRestore from JSON File
      • ๐Ÿ“˜Import from Recovery Phrase
      • ๐Ÿ“‘Import from Raw Seed
      • ๐Ÿ”—Import Proxied Account(s)
      • ๐Ÿ‘€Add Watch-only account
      • ๐Ÿ“ฑAttach External QR Signer
      • ๐Ÿ’พAttach Ledger Device
    • EXPORT ACCOUNT(S)
      • ๐Ÿ“คExport an Account
      • ๐Ÿ“คExport all Accounts
    • ๐ŸชชManage Identity
    • ๐Ÿ›ก๏ธManage Proxies
    • ๐ŸคSocial Recovery
    • ๐Ÿ”„Switch Chain
    • ๐Ÿ–‡๏ธAny Chain Mode
    • ๐Ÿ–ฅ๏ธSelect Remote Node
    • ๐Ÿ’ฑSelect Currency
    • ๐Ÿ“‚Organize Accounts in Profiles
    • โœˆ๏ธSend Fund
    • STAKE
      • ๐Ÿ‘จโ€๐Ÿ’ผStake Solo (Nominate)
      • ๐ŸŠโ€โ™‚๏ธStake in Pool
        • Join a Pool
        • Create a Pool
    • GOVERNANCE
      • ๐Ÿ—ณ๏ธVote
      • ๐Ÿฅ‚Delegate
    • SETTINGS
      • ๐Ÿ‡ฆ๐Ÿ‡ฎSwitch Language
      • ๐Ÿ”‘Login Password
      • ๐ŸงชEnable Testnet Chains
      • ๐Ÿ“ทAllow Camera Access
      • ๐Ÿ•ธ๏ธManage Website Access
    • HELP & SUPPORT
      • โ”FAQs
      • ๐ŸŒSocial Media
    • LEGAL & SECURITY
      • ๐Ÿ”Security
      • ๐Ÿ•ด๏ธPrivacy Policy
  • Metamask Snap User Guide
    • Installing PolkaGate Snap
    • Snap Home
    • How to Transfer Funds Using the Snap
    • Stake Polkadot tokens with Metamask
    • How to Work with the Snap's main dApp
    • How to Integrate My dApp with PolkaGate snap
    • FAQs
Powered by GitBook
On this page
  1. Metamask Snap User Guide

How to Integrate My dApp with PolkaGate snap

For Developers Only

To connect with the injected Snap, start by adding the @polkagate/extension-dapp package to your dApp. Use web3Enable('your-app-name') to fetch the injected extensions, including PolkaGate Snap. If you only want to enable the Snap and not other extensions, call web3Enable('snapOnly'). After that, you can access your Snap account(s) using web3Accounts(). Below is a simple code example illustrating these processes:

import { web3Accounts, web3Enable } from '@polkagate/extension-dapp';

web3Enable('your-dapp-name').then((extensions) => {
  console.log('All injected extensions:', extensions);
});

web3Accounts().then((accounts) => {
  const account = accounts.find((acc) => acc.meta.source === 'polkagate-snap');
  console.info('Snap account:', account);
});

This integration allows your dApp to interact seamlessly with the PolkaGate snap through the injected information within the window. These are familiar calls if you've worked with other existing Polkadot ecosystem extensions. The rest remains the same.

PreviousHow to Work with the Snap's main dAppNextFAQs

Last updated 10 months ago