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

@walletconnect/universal-provider

Package Overview
Dependencies
Maintainers
12
Versions
354
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.17.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
393K
increased by9.18%
Maintainers
12
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 05 Nov 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