wallet_connect

Creator: coderz1093

Last updated:

0 purchases

Default Cover

Languages

Categories

Add to Cart

Description:

wallet connect

Wallet Connect

Wallet Connect client in dart highly inspired from wallet-connect-kotlin by Trust Wallet.
Usage #
import 'package:wallet_connect/wallet_connect.dart';
copied to clipboard

Create instance of Wallet connect client and define callbacks.

final wcClient = WCClient(
onConnect: () {
// Respond to connect callback
},
onDisconnect: (code, reason) {
// Respond to disconnect callback
},
onFailure: (error) {
// Respond to connection failure callback
},
onSessionRequest: (id, peerMeta) {
// Respond to connection request callback
},
onEthSign: (id, message) {
// Respond to personal_sign or eth_sign or eth_signTypedData request callback
},
onEthSendTransaction: (id, tx) {
// Respond to eth_sendTransaction request callback
},
onEthSignTransaction: (id, tx) {
// Respond to eth_signTransaction request callback
},
);
copied to clipboard

Create WCSession object from wc: uri.

final session = WCSession.from(wcUri);
copied to clipboard

Create WCPeerMeta object containing metadata for your app.

final peerMeta = WCPeerMeta(
name: 'Example Wallet',
url: 'https://example.wallet',
description: 'Example Wallet',
icons: [],
);
copied to clipboard

Connect to a new session.

wcClient.connectNewSession(session: session, peerMeta: peerMeta);
copied to clipboard

Or connect to a saved session (from step 8).

wcClient.connectFromSessionStore(sessionStore);
copied to clipboard

Approve a session connection request.

wcClient.approveSession(
accounts: [], // account addresses
chainId: 1, // chain id
);
copied to clipboard

Or reject a session connection request.

wcClient.rejectSession();
copied to clipboard

Get active session from sessionStore getter to save for later use.

final sessionStore = wcClient.sessionStore;
copied to clipboard

Approve a sign transaction request by signing the transaction and sending the signed hex data.

wcClient.approveRequest<String>(
id: id,
result: signedDataAsHex,
);
copied to clipboard

Approve a send transaction request by sending the transaction hash generated from sending the transaction.

wcClient.approveRequest<String>(
id: id,
result: transactionHash,
);
copied to clipboard

Approve a sign request by sending the signed data hex generated.

wcClient.approveRequest<String>(
id: id,
result: signedDataAsHex,
);
copied to clipboard

Or reject any of the requests above by specifying request id.

wcClient.rejectRequest(id: id);
copied to clipboard

Disconnect from a connected session locally.

wcClient.disconnect();
copied to clipboard

Permanently close a connected session.

wcClient.killSession();
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.