Socket
Socket
Sign inDemoInstall

@walletconnect/sign-client

Package Overview
Dependencies
11
Maintainers
6
Versions
306
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@walletconnect/sign-client


Version published
Weekly downloads
314K
decreased by-18.27%
Maintainers
6
Created
Weekly downloads
 

Package description

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

Readme

Source

@walletconnect/sign-client

Sign Client for WalletConnect Protocol

Description

This library provides a Sign Client for WalletConnect v2.0 Protocol for both Dapps and Wallets. Integration will differ from the perspective of each client as the Proposer and Responder, respectively. It's compatible with NodeJS, Browser and React-Native applications (NodeJS modules required to be polyfilled for React-Native)

Documentation

Check out documentation here.

Also available quick start for Dapps and for Wallets

License

Apache 2.0

Keywords

FAQs

Last updated on 16 Feb 2023

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc