Sign inDemoInstall


Package Overview
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies



This library aims to provide an abstract class to simplify to wallet implementation for CIP-0045

Version published
Weekly downloads
decreased by-17.35%
Weekly downloads



Cardano Peer Connect

Tests Release Bundle Publish conventionalcommits

This library aims to provide simple interfaces to implement CIP-0045 for dApps and wallets. If you want to see cardano-peer-connect in action, please visit the cip-0045-demo-implementation repository.

Getting Started

npm i @fabianbormann/cardano-peer-connect

Infos for usage in the wallet

Extend the base CardanoPeerConnect class for your wallet:

class BoostPeerConnect extends CardanoPeerConnect {
  constructor(name: string, apiVersion: string, icon: string) {
      name: name,
      version: apiVersion,
      icon: icon,

    //further actions to let you wallet know about the new connection
    // ...

  // and implement all CIP-30 functions
  getRewardAddresses(): Promise<Cbor[]> {
    return new Promise((resolve, reject) => {
      //in here you determine the reward addresses for yur wallet used
      const rewardAddresses = [

      return resolve(rewardAddresses);


Then create an instance of that class in your code and add a callback to let your wallet know about the connection status.

import {
} from '@fabianbormann/cardano-peer-connect';
import { IConnectMessage } from '@fabianbormann/cardano-peer-connect/dist/src/types';

// the id the dapp is showing you.
const dAppIdentifier = 'bYUh6Bn6A........388LR1JCrED';

peerConnect.value = new BoostPeerConnect(
  'Your wallet name',
  '<img src="data:image/png;base64,iVB.....>' //your wallet logo

 * Define a callback to handle all connection attempts. This will be called by the DApp when a connection is
 * tried to be established.
peerConnect.value.setOnConnect((message: IConnectMessage) => {
  connectStatus.value = message;

  if (!message.dApp.address) {
    // every dapp should send some infos about it.

  if (message.dApp.address !== dAppIdentifier) {
    // the connected dapp id should match the one that the user requested

  if (message.error) {
    //handle the connection error (message.errorMessage)

  //now handle the message and show which dapp was connected to your wallet

// finally try to connect to the dapp
const seed = peerConnect.value.connect(

//seed will be the unique connection id between you and the dapp
//The connection is not yet established. The user needs to grant the permission to establish the connection on the
//dapp side. See next section on how a DApp must implement this.

Infos for usage in DApp site

This is the necessary minimal implementation a DApp provider has to do, to get his app connected to peer connect.

<script src=""></script>

  // Give your app some basic information that will be displayed to the client wallet when he is connecting to your DApp.
  const dAppInfo: IDAppInfos = {
    name: 'An awesome DApp',
    url: 'http://an-awesome-dapp-url.tld/'

  // Define a function that will be called when the client tries to connect to your DApp.
  const verifyConnection = (
    walletInfo: IWalletInfo,
    callback: (granted: boolean) => void
  ) => {
      window.confirm(`Do you want to connect to wallet ${} (${walletInfo.address})?`)

  const dAppConnect = new DAppPeerConnect({
    dAppInfo: dAppInfo,
    verifyConnection: verifyConnection,
    onApiInject: onApiInject, // will be call when api was successfully injected
    onApiEject: onApiEject,   // will be call when api was ejected

  // This is the code (identifier) that the client needs to enter into the wallet to connect to your dapp
  const clientConnectCode = dAppConnect.getAddress()

  // Create and insert a QR code on your DApp, so the user can scan it easily in their app

  //after the api was injected you cann call all cip-30 function on window.cardanop2p as you would on window.cardano



Last updated on 24 May 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.


Related posts

SocketSocket SOC 2 Logo


  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc