연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Wallet Connect
Wallet Connect client in dart highly inspired from wallet-connect-kotlin by Trust Wallet .
Usage
import 'package:wallet_connect/wallet_connect.dart' ;
Create instance of Wallet connect client and define callbacks.
final wcClient = WCClient (
onConnect: () {
},
onDisconnect: (code, reason) {
},
onFailure: (error) {
},
onSessionRequest: (id, peerMeta) {
},
onEthSign: (id, message) {
},
onEthSendTransaction: (id, tx) {
},
onEthSignTransaction: (id, tx) {
},
);
Create WCSession object from wc: uri.
final session = WCSession .from (wcUri);
Create WCPeerMeta object containing metadata for your app.
final peerMeta = WCPeerMeta (
name: 'Example Wallet' ,
url: 'https://example.wallet' ,
description: 'Example Wallet' ,
icons: [],
);
Connect to a new session.
wcClient.connectNewSession (session: session, peerMeta: peerMeta);
Or connect to a saved session (from step 8).
wcClient.connectFromSessionStore (sessionStore);
Approve a session connection request.
wcClient.approveSession (
accounts: [],
chainId: 1 ,
);
Or reject a session connection request.
wcClient.rejectSession ();
Get active session from sessionStore getter to save for later use.
final sessionStore = wcClient.sessionStore;
Approve a sign transaction request by signing the transaction and sending the signed hex data.
wcClient.approveRequest<String >(
id: id,
result: signedDataAsHex,
);
Approve a send transaction request by sending the transaction hash generated from sending the transaction.
wcClient.approveRequest<String >(
id: id,
result: transactionHash,
);
Approve a sign request by sending the signed data hex generated.
wcClient.approveRequest<String >(
id: id,
result: signedDataAsHex,
);
Or reject any of the requests above by specifying request id.
wcClient.rejectRequest (id: id);
Disconnect from a connected session locally.
wcClient.disconnect ();
Permanently close a connected session.
wcClient.killSession ();