walletconnect is an open source protocol for connecting decentralised applications to mobile wallets
with qr code scanning or deep linking. a user can interact securely with any dapp from their mobile
phone, making walletconnect wallets a safer choice compared to desktop or browser extension wallets.
introduction
walletconnect connects mobile & web applications to supported mobile wallets. the walletconnect session is started by scanning a qr code (desktop) or by clicking an application deep link (mobile).
walletconnect-dart-sdk is a community sdk and port of the official walletconnect-monorepo.
⚠️ at the moment, only algorand is supported!
walletconnect lets you build:
- decentralized web applications and display qr codes with qr_flutter
- mobile dapps with deep linking using url_launcher
- cross-platform wallets
once installed, you can simply connect your application to a wallet.
// create a connector
final connector = walletconnect(
bridge: 'https://bridge.walletconnect.org',
clientmeta: peermeta(
name: 'walletconnect',
description: 'walletconnect developer app',
url: 'https://walletconnect.org',
icons: [
'https://gblobscdn.gitbook.com/spaces%2f-ljjecjclrr53dct1ml7%2favatar.png?alt=media'
],
),
);
usage
dapps
initiate connection
// create a connector
final connector = walletconnect(
bridge: 'https://bridge.walletconnect.org',
clientmeta: peermeta(
name: 'walletconnect',
description: 'walletconnect developer app',
url: 'https://walletconnect.org',
icons: [
'https://gblobscdn.gitbook.com/spaces%2f-ljjecjclrr53dct1ml7%2favatar.png?alt=media'
],
),
);
// subscribe to events
connector.on('connect', (session) => print(session));
connector.on('session_update', (payload) => print(payload));
connector.on('disconnect', (session) => print(session));
// create a new session
if (!connector.connected) {
final session = await connector.createsession(
chainid: 4160,
ondisplayuri: (uri) => print(uri),
);
}
sign transaction
// set a default walletconnect provider
connector.setdefaultprovider(algorandwcprovider(connector));
// sign the transaction
final txbytes = encoder.encodemessagepack(transaction.tomessagepack());
final signedbytes = await connector.signtransaction(
txbytes,
params: {
'message': 'optional description message',
},
);
wallets
initiate connection
// create a connector
final connector = walletconnect(
uri: 'wc:8a5e5bdc-a0e4-47...tjrnmhwjmoxdfo6udk2wlhaoyq5n0u=',
clientmeta: peermeta(
name: 'walletconnect',
description: 'walletconnect developer app',
url: 'https://walletconnect.org',
icons: [
'https://gblobscdn.gitbook.com/spaces%2f-ljjecjclrr53dct1ml7%2favatar.png?alt=media'
],
),
);
// subscribe to events
connector.on('connect', (session) => print(session));
connector.on('session_request', (payload) => print(payload));
connector.on('disconnect', (session) => print(session));
manage connection
// approve session
await connector.approvesession(chainid: 4160, accounts: ['0x4292...931b3']);
// reject session
await connector.rejectsession(message: 'optional error message');
// update session
await connector.updatesession(sessionstatus(chainid: 4000, accounts: ['0x4292...931b3']));
kill session
await connector.killsession();
changelog
please see changelog for more information on what has changed recently.
contributing & pull requests
feel free to send pull requests.
please see contributing for details.
credits
license
the mit license (mit). please see license file for more information.
Comments are closed.