Skip to content

How to integrate with PolkaGate snap

G. Kami Ekbatanifard edited this page Feb 19, 2024 · 7 revisions

To connect with the injected snap, add the @polkagate/extension-dapp package to your dapp. Then, use web3Enable('your-app-name') to fetch the injected extensions, including polkagate snap. Afterward, you can access your snap account(s) by calling web3Accounts(). Below, you can find simple code 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.

Clone this wiki locally