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

@walletconnect/sign-client

Package Overview
Dependencies
Maintainers
11
Versions
378
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@walletconnect/sign-client

Sign Client for WalletConnect Protocol

  • 2.13.3-canary-a8df04214
  • npm
  • Socket score

Version published
Weekly downloads
366K
decreased by-23.87%
Maintainers
11
Weekly downloads
 
Created

What is @walletconnect/sign-client?

@walletconnect/sign-client is a JavaScript client library for WalletConnect, a protocol that enables secure connections between decentralized applications (dApps) and wallets. This package allows developers to integrate WalletConnect functionality into their applications, enabling features such as session management, message signing, and transaction handling.

What are @walletconnect/sign-client's main functionalities?

Initialize Client

This code demonstrates how to initialize the WalletConnect SignClient with a project ID and relay URL. This is the first step to start using the WalletConnect functionalities.

const { SignClient } = require('@walletconnect/sign-client');

async function initClient() {
  const client = await SignClient.init({
    projectId: 'your_project_id',
    relayUrl: 'wss://relay.walletconnect.org'
  });
  console.log('Client initialized:', client);
}

initClient();

Create Session

This code demonstrates how to create a new session with the WalletConnect client. It specifies the required namespaces, methods, chains, and events, and then waits for the session to be approved.

async function createSession(client) {
  const { uri, approval } = await client.connect({
    requiredNamespaces: {
      eip155: {
        methods: ['eth_sendTransaction', 'personal_sign'],
        chains: ['eip155:1'],
        events: ['chainChanged', 'accountsChanged']
      }
    }
  });
  console.log('Session URI:', uri);
  const session = await approval();
  console.log('Session approved:', session);
}

createSession(client);

Sign Message

This code demonstrates how to sign a message using the WalletConnect client. It sends a request to sign a message and logs the signed message.

async function signMessage(client, session) {
  const message = 'Hello, WalletConnect!';
  const result = await client.request({
    topic: session.topic,
    chainId: 'eip155:1',
    request: {
      method: 'personal_sign',
      params: [message, session.accounts[0]]
    }
  });
  console.log('Signed message:', result);
}

signMessage(client, session);

Send Transaction

This code demonstrates how to send a transaction using the WalletConnect client. It constructs a transaction object and sends it, then logs the result.

async function sendTransaction(client, session) {
  const tx = {
    from: session.accounts[0],
    to: '0xRecipientAddress',
    data: '0x',
    value: '0x0',
    gas: '0x5208'
  };
  const result = await client.request({
    topic: session.topic,
    chainId: 'eip155:1',
    request: {
      method: 'eth_sendTransaction',
      params: [tx]
    }
  });
  console.log('Transaction result:', result);
}

sendTransaction(client, session);

Other packages similar to @walletconnect/sign-client

Keywords

FAQs

Package last updated on 10 Jul 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