0.20.2 • Published 12 days ago
@metamask/sdk-communication-layer v0.20.2
MetaMask SDK Communication Layer
Installation
yarn add @metamask/sdk-communication-layer
Using
Dapp
RemoteCommunication = new RemoteCommunicationLib({
commLayer: 'socket'
});
const { channelId, pubKey } = RemoteCommunication.generateChannelId();
const linkParams = `channelId=${encodeURIComponent(
channelId,
)}&comm=${encodeURIComponent(
'socket'
)}&pubkey=${encodeURIComponent(pubKey)}`;
console.log("Connect to", linkParams)
RemoteCommunication.on('message', (message) => {
console.log("New Message", message)
})
RemoteCommunication.on('clients_ready', (message) => {
console.log("Clients now connected!")
})
MetaMask
const url = new URL(this.state.urlToConnect);
// https://metamask.app.link/connect?channelId=4cddce59-c4ea-4c70-9dbf-d1ddbe8f7a9f&comm=socket&pubkey=BCCKuS6Z26iZkxA1oB69X9DN73dlCYEQa46d0id8MCXdshRHGqI4rVuIeXjMS2vrlq7PkD4nbzb7gEFn%2FJfHz4E%3D
console.log(url.searchParams);
const otherPublicKey = url.searchParams.get('pubkey');
const channelId = url.searchParams.get('channelId');
console.log('otherPublicKey', otherPublicKey);
console.log('channelId', channelId);
RemoteCommunication = new RemoteCommunicationLib({
commLayer: 'socket',
otherPublicKey,
});
RemoteCommunication.connectToChannel(channelId);
RemoteCommunication.on('clients_ready', () => {
this.setState({ connected: true });
});
RemoteCommunication.on('message', (message) => {
console.log("New message", message);
});
0.20.2
12 days ago
0.19.0
13 days ago
0.18.5
1 month ago
0.18.4
1 month ago
0.18.2
2 months ago
0.18.1
2 months ago
0.18.0
2 months ago
0.17.0
2 months ago
0.16.0
3 months ago
0.15.0
3 months ago
0.14.3
4 months ago
0.14.2
4 months ago
0.11.0
7 months ago
0.10.1
7 months ago
0.12.0
7 months ago
0.11.1
7 months ago
0.13.0
6 months ago
0.12.1
6 months ago
0.14.0
6 months ago
0.12.2
6 months ago
0.14.1
6 months ago
0.12.3
6 months ago
0.10.0
7 months ago
0.9.0
7 months ago
0.8.0
8 months ago
0.7.1
8 months ago
0.6.2
8 months ago
0.5.3
10 months ago
0.5.0
10 months ago
0.4.0
11 months ago
0.7.0
8 months ago
0.6.1
9 months ago
0.5.2
10 months ago
0.6.0
9 months ago
0.4.2
11 months ago
0.3.3
11 months ago
0.3.0
12 months ago
0.3.2
12 months ago
0.2.5
1 year ago
0.2.4
1 year ago
0.2.1
1 year ago
0.2.0
1 year ago
0.2.3
1 year ago
0.2.2
1 year ago
0.1.0
1 year ago
0.0.1-beta.4
2 years ago
0.0.1-beta.3
2 years ago
0.0.1-beta.2
2 years ago