Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@walletconnect/universal-provider

Package Overview
Dependencies
Maintainers
13
Versions
350
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@walletconnect/universal-provider

Universal Provider for WalletConnect Protocol

  • 2.16.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
354K
decreased by-3.5%
Maintainers
13
Weekly downloads
 
Created

What is @walletconnect/universal-provider?

@walletconnect/universal-provider is a JavaScript library that allows developers to integrate WalletConnect functionality into their applications. WalletConnect is an open protocol for connecting decentralized applications (dApps) to mobile wallets with QR code scanning or deep linking. This package provides a universal provider that supports multiple blockchain networks and wallet types, making it easier to manage wallet connections and interactions.

What are @walletconnect/universal-provider's main functionalities?

Initialize WalletConnect Provider

This code initializes the WalletConnect Universal Provider with the necessary configuration, including project ID, relay URL, and metadata for the dApp.

const { UniversalProvider } = require('@walletconnect/universal-provider');

const provider = new UniversalProvider({
  projectId: 'your_project_id',
  relayUrl: 'wss://relay.walletconnect.org',
  metadata: {
    name: 'My DApp',
    description: 'My decentralized application',
    url: 'https://mydapp.com',
    icons: ['https://mydapp.com/icon.png']
  }
});

Connect to Wallet

This code demonstrates how to connect to a wallet using the Universal Provider. It specifies the required namespaces, methods, chains, and events, and then logs the connected session.

async function connectWallet() {
  const session = await provider.connect({
    requiredNamespaces: {
      eip155: {
        methods: ['eth_sendTransaction', 'personal_sign'],
        chains: ['eip155:1'],
        events: ['chainChanged', 'accountsChanged']
      }
    }
  });
  console.log('Connected session:', session);
}

connectWallet();

Send Transaction

This code demonstrates how to send a transaction using the Universal Provider. It constructs a transaction object and sends it using the 'eth_sendTransaction' method.

async function sendTransaction() {
  const tx = {
    from: '0xYourAddress',
    to: '0xRecipientAddress',
    value: '0xAmountInHex',
    gas: '0xGasLimitInHex'
  };
  const result = await provider.request({
    method: 'eth_sendTransaction',
    params: [tx]
  });
  console.log('Transaction result:', result);
}

sendTransaction();

Other packages similar to @walletconnect/universal-provider

Keywords

FAQs

Package last updated on 18 Sep 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc