What is Plutonication
Examples in Javascript
Plutonication allows users to connect PlutoWallet to other dApps seamlessly on any platforms, accross multiple codebases. DApp just generates a QR code and once it is scanned in the wallet, they will pair and the wallet will be able to receive transaction requests from the dApp. It works on the same principle as WalletConnect protocol.
How to connect
import io from 'socket.io-client';
// Change the URL, if you want to use your own endpoint.
const socket = io("wss://plutonication-acnha.ondigitalocean.app/");
Plutonication uses Socket.IO.
To connect your to PlutonicationServer, just connect to
wss://plutonication-acnha.ondigitalocean.app/
.
Plutonication is fully open-sourced. One of the benefits this brings is that you can deploy your own Plutonication Server. You do not have to rely on our infrastructure.
On connect
// Wait for the client to connect
await new Promise((resolve) => {
socket.on("connect", () => {
console.log("Connected")
resolve()
})
})
Event handler that is fired whenever someone connects.
Useful for debugging.
It is fired on the client as well and it is useful getting to know that the client connected successfully to the server.
On create_room
socket.emit("create_room", {
Room: accessCredentials.key
});
Creates a new websocket room. Intended to be used by dApps.
On pubkey
socket.on("pubkey", (pubkey /* string type */) => {
console.log("Wallet public key: " + pubkey)
})
The first event emitted by wallet.
One of the side-effects is joining a given room. Meaning that the wallet does not need to emit "create_room" anymore
On sing_payload
socket.emit("sign_payload", {
Data: payloadJson, // SignerPayloadJSON type
Room: accessCredentials.key
})
Event handler used by dApps. Used when requesting signature from wallet.
You can expect the wallet to emit either payload_signature
event or
payload_signature_rejected
event.
On payload_signature
socket.on("payload_signature", (data /* SignerResult type */) => {
const signature = data.signature
console.log("Payload signature: " + signature)
})
Event handler used by wallet, when wallet decides to sign given payload.
On payload_signature_rejected
socket.on("payload_signature_rejected", () => {
// react to the rejection
})
Event handler used by wallet, when wallet decides to reject the signing of given payload.
On sign_raw
socket.emit("sign_raw", {
Data: rawMessage, // SignerPayloadRaw type
Room: accessCredentials.key
})
Event handler used by dApps. Used when requesting signature from wallet.
You can expect the wallet to emit either raw_signature
event or raw_signature_rejected
event.
On raw_signature
socket.on("raw_signature", (data /* SignerResult type */) => {
const signature = data.signature
console.log("Raw signature: " + signature)
})
Event handler used by wallet, when wallet decides to sign given raw message.
On raw_signature_rejected
socket.on("raw_signature_rejected", () => {
// react to the rejection
})
Event handler used by wallet, when wallet decides to reject the signing of given raw message.