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

PreviousHow to Work with the Snap's main dAppNextFAQs

Last updated 1 year ago

CtrlK

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.