1.16.1 • Published 2 months ago

@walletconnect/web3wallet v1.16.1

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
2 months ago

@walletconnect/web3wallet

Description

The Web3Wallet SDK streamlines the integration process, making it easier for wallet developers to include the authentication and transaction signing features necessary for their users to connect and interact with all sorts of apps — now and in the future.

Getting Started

Install

npm install @walletconnect/web3wallet

Wallet Usage

  1. Initialization
import { Core } from "@walletconnect/core";
import { Web3Wallet } from "@walletconnect/web3wallet";

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

const web3wallet = await Web3Wallet.init({
  core, // <- pass the shared `core` instance
  metadata: {
    name: "Demo app",
    description: "Demo Client as Wallet/Peer",
    url: "www.walletconnect.com",
    icons: [],
  },
});
  1. Sign Session Approval
web3wallet.on("session_proposal", async (proposal) => {
  const session = await web3wallet.approveSession({
    id: proposal.id,
    namespaces,
  });
});
await web3wallet.core.pairing.pair({ uri });
  1. Sign Session Rejection
web3wallet.on("session_proposal", async (proposal) => {
  const session = await web3wallet.rejectSession({
    id: proposal.id,
    reason: getSdkError("USER_REJECTED_METHODS"),
  });
});
  1. Sign Session Disconnect
await web3wallet.disconnectSession({
  topic,
  reason: getSdkError("USER_DISCONNECTED"),
});
  1. Responding to Sign Session Requests
web3wallet.on("session_request", async (event) => {
  const { id, method, params } = event.request;
  await web3wallet.respondSessionRequest({ id, result: response });
});
  1. Updating a Sign Session
await web3wallet.updateSession({ topic, namespaces: newNs });
  1. Updating a Sign Session
await web3wallet.extendSession({ topic });
  1. Emit Sign Session Events
await web3wallet.emitSessionEvent({
  topic,
  event: {
    name: "accountsChanged",
    data: ["0xab16a96D359eC26a11e2C2b3d8f8B8942d5Bfcdb"],
  },
  chainId: "eip155:1",
});
  1. Handle Sign Events
web3wallet.on("session_proposal", handler);
web3wallet.on("session_request", handler);
web3wallet.on("session_delete", handler);
  1. SIWE with a dapp
const iss = `did:pkh:eip155:1:${address}`;
web3wallet.on("auth_request", async (event) => {
  // format the payload
  const message = web3wallet.formatMessage(event.params.cacaoPayload, iss);
  // prompt the user to sign the message
  const signature = await wallet.signMessage(message);
  // respond
  await web3wallet.respondAuthRequest(
    {
      id: args.id,
      signature: {
        s: signature,
        t: "eip191",
      },
    },
    iss,
  );
});

await web3wallet.core.pairing.pair({ uri: request.uri, activatePairing: true });
  1. Handle Auth Events
web3wallet.on("auth_request", handler);

Already using Sign or Auth? Check our migration guide

1.16.0-rc-0

3 months ago

1.16.0-rc-1

3 months ago

1.16.1-canary-0

2 months ago

1.15.3

3 months ago

1.16.1

2 months ago

1.16.0-canary-0

3 months ago

1.16.0

3 months ago

1.15.3-rc-tma-1

3 months ago

1.15.3-rc-tma-0

3 months ago

1.16.1-rc-0

2 months ago

1.14.3

4 months ago

1.14.2

4 months ago

1.14.2-canary-lm.1

4 months ago

1.14.2-canary-lm.2

4 months ago

1.14.2-canary-lm.3

4 months ago

1.14.2-canary-lm.4

4 months ago

1.14.0-canary-lm.8

4 months ago

1.14.2-canary-lm.5

4 months ago

1.14.1-canary-lm.9

4 months ago

1.14.2-canary-lm.6

4 months ago

1.15.2-rc-1

3 months ago

1.15.2-rc-0

3 months ago

1.14.2-canary-lm.0

4 months ago

1.14.3-rc

4 months ago

1.15.0

4 months ago

1.15.2

3 months ago

1.15.1

3 months ago

1.15.1-rc-0

3 months ago

1.15.0-rc-0

4 months ago

1.14.1

4 months ago

1.14.0-canary-lm.7

4 months ago

1.14.0-canary-lm.6

4 months ago

1.14.0-canary-lm.4

4 months ago

1.14.0-canary-lm.1

4 months ago

1.14.0

4 months ago

1.14.0-canary-lm.0

4 months ago

1.14.0-rc.0

4 months ago

1.13.0-canary.4

4 months ago

1.13.0-canary.5

4 months ago

1.13.0-canary.3

4 months ago

1.13.0-canary.1

5 months ago

1.13.0-canary.2

5 months ago

1.12.3-link-mode-0

5 months ago

1.13.0

5 months ago

1.13.0-rc-0

5 months ago

1.12.3

6 months ago

1.12.2

7 months ago

1.12.2-rc-5c0535a6

7 months ago

1.12.1

7 months ago

1.12.1-rc-20e12b0a

7 months ago

1.12.1-rc-a7fe9fc1

7 months ago

1.12.1-rc-ce04a9aa

7 months ago

1.12.0

8 months ago

1.11.2-req-q.0

8 months ago

1.11.2-rc-0

9 months ago

1.11.2

9 months ago

1.11.1

9 months ago

1.11.0

9 months ago

1.10.3

9 months ago

1.10.2

10 months ago

1.10.2-rc-ec7dcc

10 months ago

1.10.1

11 months ago

1.10.0-canary-ws.1

11 months ago

2.11.0-canary-ws.0

11 months ago

1.10.0-canary-e3096

11 months ago

1.10.0-canary-0ab57

11 months ago

1.10.1-rc-7b41511

12 months ago

1.10.0

1 year ago

1.9.5-canary-8

1 year ago

1.8.7-rc-e8b829

1 year ago

1.9.1

1 year ago

1.9.0

1 year ago

1.8.5-409b14d4

1 year ago

1.8.8-canary-1

1 year ago

1.8.7-canary.0

1 year ago

1.8.6-e9ace057

1 year ago

1.8.6-db80be53

1 year ago

1.8.8

1 year ago

1.8.7

1 year ago

1.9.5

1 year ago

1.8.6

1 year ago

1.9.4

1 year ago

1.9.3

1 year ago

1.9.2

1 year ago

1.9.4-canary-8

1 year ago

1.9.5-rc-0.1

1 year ago

1.9.4-canary-01

1 year ago

1.8.5

1 year ago

1.8.2

2 years ago

1.7.3

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.7.6

2 years ago

1.7.5

2 years ago

1.7.4

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago