Quantum
  • Welcome to Quantum
  • Developer portal
    • Pricing
  • Self-Custody Infrastructure
    • Pincode Management
    • Private Key Management
  • Quickstart guide
  • Authentication
    • API Authentication
  • Faucets
  • Networks & URLs
  • Walletify Api
    • Overview
    • Getting started
    • User Management
    • Signing Methods
    • Testnet Assets
    • Basic Guides
      • Create a user
      • Retrieve a user
      • Update a user
      • Delete a user
      • Create a signing method
      • Update a signing method
      • Delete a signing method
      • Create a wallet
      • Retrieve wallet
      • Archive a wallet
      • Import a wallet
      • Export a wallet
      • Retrieve native balance
      • Retrieve ERC20 tokens
      • Retrieve NFTs
      • Transfer a native token
      • Transfer an ERC20 token
      • Transfer an NFT
      • Transfer a fungible token
      • Signatures
      • Read a contract
      • Execute a contract call
      • Get Transaction status
      • Resubmit a transaction
      • Get wallet events
      • Webhooks
    • Advanced Guides
      • Burn an NFT
      • Filter Spam NFTs
      • Filter NSFW NFTs
      • SWAP Token Pairs
      • Gasless/Meta Transactions
      • Sign RAW Transactions
      • Using Fiat Onramp with Walletify-API
      • Deploy an Ethereum contract
      • Integrate with WalletConnect
      • Set Up NFT Token Gating
      • Chain Specific Fields
      • Integrate with WalletConnect
      • Encrypted PIN Transfer
  • Nft Wizard Api
    • Overview
    • Getting started
    • Basic Guides
      • Get any NFT info
      • Get any NFT contract
      • Get NFTs by any wallet
      • Get wallets by any NFT
      • Create contract
      • Retrieve Contract
      • Delete Contract
      • Check Contract Status
      • Retrieve Contract Metadata
      • Update Contract Metadata
      • Create Token-type (NFT template)
      • Retrieve Token-type (NFT template)
      • Delete Token-type (NFT Template)
      • Check Token-type Status
      • Retrieve Token-type Metadata
      • Update Token-type Metadata
      • Mint an NFT
      • Batch Mint NFTs
      • Update NFT Metadata
      • Retrieve NFT Metadata
      • Add Audio to your NFTs
      • Add Video to your NFTs
      • Store NFT Media
      • Webhooks
    • Advanced Guides
      • Mass Minting
      • Speed Up Minting
      • Dynamic NFTs
      • Configure Royalties
      • Create Company Minter Wallet
      • Retrieve Company Minter Wallets
      • Store NFT Metadata on IPFS
      • View NFT on sandbox/testnet
    • NFT Configuration
      • Attributes
      • Animation & Media
      • Collection Info
      • Max Supply
      • Mint Number
      • Burnable
      • Metadata Storage
  • TMINTER API
    • Overview
    • Getting started
    • Basic Guide
      • Retrieve Any NFT Information
      • Retrieve NFT Contract Information
      • Retrieve NFTs by Wallet Address
      • Retrieve Wallets by NFT
      • Create a New NFT Contract
      • Retrieve a Contract
      • Delete a Contract
      • Check Contract Status
      • Retrieve Contract Metadata
      • Update Contract Metadata
      • Create Token-Type
      • Retrieve Token-Type
      • Delete Token-Type
      • Check Token-Type Status
      • Retrieve Token-Type Metadata
      • Update Token-Type Metadata
      • Mint a Single NFT
      • Batch Mint Multiple NFTs
      • Update NFT Metadata
      • Retrieve NFT Metadata
      • Add Audio to Your NFTs
      • Add Video to Your NFTs
      • Store NFT Media
      • Webhooks for NFT Events
    • Advance Guide
      • Dynamic NFT Creation
      • Token Economics and Supply Control
      • Advanced Minting: Royalty Distribution
      • Cross-Chain NFT Minting
      • NFT Sharding (Fractional Ownership)
      • Batch NFT Minting with Custom Metadata
      • Add Interactivity to NFTs
      • Advanced Media Integration: VR and AR
      • Webhook Triggers for Automated Processes
Powered by GitBook
On this page
  1. Walletify Api
  2. Advanced Guides

Integrate with WalletConnect

PreviousChain Specific FieldsNextEncrypted PIN Transfer

Last updated 9 months ago

WalletConnect is an open-source protocol designed to provide users with a secure way to link their cryptocurrency wallets to DApp websites. This technology enables seamless, direct peer-to-peer interactions between a user's wallet and a DApp, eliminating the need for intermediaries or browser extensions.

Quantum's Wallet API enhances this experience by bridging the gap between WalletConnect and DApp websites. This integration allows for efficient interaction with blockchain assets and operations, ensuring a smooth and secure connection for users engaging with decentralized applications.

📘

This guide is intended for wallet app developers looking to implement WalletConnect.

Getting Started

The quickest way to get started is by cloning the repo for our (Nextjs/React) and running it locally.

You can test your integration by using it in conjunction with the .

Obtain Project ID

Head over to to sign in or sign up. Create your project and copy its associated Project ID. We will need this in a later step.

Install Packages

Install the Web3Wallet SDK package.

Shell

npm install @walletconnect/web3wallet

Initialization

Create a new instance of Core and initialize it with the Project ID created earlier. Next, create a web3Wallet instance while passing a metadata object containing metadata about your app.

JavaScript

import { Core } from '@walletconnect/core'
import { Web3Wallet } from '@walletconnect/web3wallet'

let core, web3wallet

core = new Core({
  projectId: process.env.PROJECT_ID
})

web3wallet = await Web3Wallet.init({
  core,
  metadata: {
    name: 'quantum Demo',
    description: 'quantum WalletConnect Demo App',
    url: 'https://walletconnect.quantum.io',
    icons: ['https://storage.quantum.io/brand/icon-gradient-background.png']
  }
})

Pairing

JavaScript

await web3wallet.core.pairing.pair({ uri })

The connection between a dapp and your wallet is established using a pairing URI which can be obtained through one of two ways:

  1. Passed as a URL parameter when your wallet is opened by the Web3Modal ex. ?uri=...

  2. Copy/pasted into your wallet app

Events

Once the pairing has been established, the dapp is then able to send requests to your wallet which can be approved/rejected by the user.

Typically, dapps will follow one of two flows:

  1. A session proposal followed by one or more session requests. This is used when the dapp needs the user to perform specific actions, such as sending a transaction or signing a message.

  2. A single auth request used to authenticate the user. This is done by requesting a signed message.

Session Proposal

The session_proposal event is emitted when a dapp initiates a new session with a user's wallet. The event will include a proposal object with information about the dapp and requested permissions.

You will want to display a dialog for the user to select their desired wallets and approve or reject the session.

JavaScript

web3wallet.on('session_proposal', (event) => {
  // Show session proposal dialog
})

Approve Session

To approve the session, call approveSession and pass in the proposal.id and approved namespaces. Your namespaces will depend on the user’s selected wallets and respective chains.

JavaScript

import { buildApprovedNamespaces } from "@walletconnect/utils"

const { id, params } = event
const supportedNamespaces = {
  // accounts: ...
	// chains: ...
	events: ['chainChanged', 'accountsChanged'],
  methods: ['eth_sendTransaction', 'personal_sign', 'eth_sign', 'eth_signTransaction', 'eth_signTypedData']
}
const approvedNamespaces = buildApprovedNamespaces({
  proposal: params,
  supportedNamespaces,
})

await web3wallet.approveSession({
  id: proposal.id,
  namespaces
})

Reject Session

To reject the session proposal, call the rejectSession method. The getSdkError function comes from @walletconnect/utils.

JavaScript

import { getSdkError} from "@walletconnect/utils"

await web3wallet.rejectSession({
  id: proposal.id,
  reason: getSdkError('USER_REJECTED_METHODS')
})

Disconnect Session

If the dapp decides to disconnect the session, the session_delete event will be emitted. Your app should listen for this event in order to update the UI.

You can use the getActiveSessions function to get an updated list of active session pairings.

JavaScript

web3wallet.on('session_delete', (event) => {
  // Update UI with web3wallet.getActiveSessions()
})

To disconnect a session from your wallet, call the disconnectSession function and pass in the topic and reason.

JavaScript

await web3wallet.disconnectSession({
  topic,
  reason: getSdkError('USER_DISCONNECTED')
})

Session Request

The session_request event is triggered by a dapp when it needs the wallet to perform a specific action, such as signing a message. The event contains a request object which will vary depending on the method requested.

JavaScript

web3wallet.on('session_request', (event) => {
  // Show session request dialog
})

Example: Sign Message

For example if the dapp asks for a signed message by requesting the personal_sign method, you will need to implement the logic for signing the message and then call respondSessionRequest with the resulting signature.

JavaScript

const { topic, params, id } = event
const [message, walletAddress] = params.request.params

// Find specified wallet and use it to sign the message
const wallet = EXAMPLE.findWallet(walletAddress)
const signature = EXAMPLE.signMessage(wallet, message)

const response = { id, jsonrpc: '2.0', result: signature }
await web3wallet.respondSessionRequest({ topic, response })

Auth Request

The auth_request event is emitted when there is a request for authentication from a dapp. Your wallet should respond to this request by signing the provided message and returning the resulting signature. If a user has multiple wallets, you should allow them to select which one they want to authenticate with.

JavaScript

const { id, params } = event
const iss = `did:pkh:eip155:1:${wallet.address}`
const message = web3wallet.formatMessage(params.cacaoPayload, iss)

const signature = EXAMPLE.signMessage(wallet, message)
  
await web3wallet.respondAuthRequest(
  {
    id,
    signature: {
      s: signature,
      t: 'eip191'
    }
  },
  iss
)

You can also reject the auth_request by providing an error object instead.

JavaScript

const iss = `did:pkh:eip155:1:${wallet.address}`
await web3wallet.respondAuthRequest(
  {
    id: event.id,
    error: getSdkError('USER_REJECTED')
  },
  iss
)

Final Step

You can test the pairing flow with the . Use the copy icon on the top-right of the Web3Modal to copy the pairing URI.

While this guide only covers essential events, you can find more detailed information about all the different event types on the .

See the for details on how to build the namespaces object using the buildApprovedNamespaces helper function.

To see a list of possible methods, you can refer to the relevant .

Refer to the for examples of other methods.

The last step to complete your integration is to submit your app for approval on the . Make sure to follow the to ensure your app meets all the necessary criteria.

example wallet app
WalletConnect demo dapp
WalletConnect Cloud
WalletConnect demo dapp
WalletConnect documentation
example wallet app
WalletConnect documentation
example wallet app
WalletConnect Cloud Explorer
Explorer Guidelines