Skip to content

Portal Integration Guide

Portal is an embedded blockchain infrastructure company that powers companies with an end to end platform for key management for self-custodial wallets (MPC and AA), security firewall, and web3 protocol connect kit.

A combination of Portal and Account Kit allows you to have robust key management and security, while also exploring everything that web3 has to offer with smart accounts for your users.

Integration

Check out Portal's developer docs to learn more about Portal. If you want to get quick access to their SDKs, please reach out via this form.

Install the Portal SDK

Using PortalSigner in the aa-signers package requires installation of the @portal-hq/web SDK. aa-signers lists it as optional dependency.

bash
npm install --save @portal-hq/web
bash
yarn add @portal-hq/web

Create a SmartAccountSigner

Next, setup the Portal SDK and create an authenticated PortalSigner using the aa-signers package:

ts
import { sepolia } from "@alchemy/aa-core";
import { PortalSigner } from "@alchemy/aa-signers/portal";

export const createPortalSigner = async () => {
  const portalSigner = new PortalSigner({
    autoApprove: true,
    gatewayConfig: `${sepolia.rpcUrls.alchemy.http}/${process.env.ALCHEMY_API_KEY}`,
    chainId: sepolia.id,
  });

  await portalSigner.authenticate();

  return portalSigner;
};

Use it with Modular Account

Let's see it in action with aa-alchemy:

ts
import { createModularAccountAlchemyClient } from "@alchemy/aa-alchemy";
import { sepolia } from "@alchemy/aa-core";
import { createPortalSigner } from "./portal";

const chain = sepolia;

const provider = await createModularAccountAlchemyClient({
  apiKey: "ALCHEMY_API_KEY",
  chain,
  signer: await createPortalSigner(),
});
ts
import { sepolia } from "@alchemy/aa-core";
import { PortalSigner } from "@alchemy/aa-signers/portal";

export const createPortalSigner = async () => {
  const portalSigner = new PortalSigner({
    autoApprove: true,
    gatewayConfig: `${sepolia.rpcUrls.alchemy.http}/${process.env.ALCHEMY_API_KEY}`,
    chainId: sepolia.id,
  });

  await portalSigner.authenticate();

  return portalSigner;
};