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.com/");
                 Plutonication uses Socket.IO.
                    To connect your to PlutonicationServer, just connect to
                    wss://plutonication.com/
                    .
                
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 connect_dapp
                    
await socket.emit("connect_dapp", {
    Room: accessCredentials.key
});
                    
                
                The first event emitted by dApp.
Joins the given room.
Learn more about the concept of rooms: https://socket.io/docs/v3/rooms/
connect_wallet
                    
await walletSocket.emit("connect_wallet", {
    Data: pubkey,
    Room: accessCredentials.key,
})
                    
                
                The first event emitted by wallet.
Joins the given room. Submits the pubkey/address to all other clients connected in the same room.
Learn more about the concept of rooms: https://socket.io/docs/v3/rooms/
On pubkey
                    
socket.on("pubkey", (pubkey /* string type */) => {
    console.log("Wallet public key: " + pubkey)
})
                    
                
                This event handler confirms that the wallet has successfully connected.
It also receives information about the connected wallet, including it's pubkey/address.
On dapp_connected
                    
walletSocket.on("dapp_connected", async () => {
    await walletSocket.emit("pubkey", { Data: pubkey, Room: room })
})
                    
                
                Handles edge case when dapp connects later than the wallet.
Is also useful for handling multiple dApp connections simultaneously.
On confirm_dapp_connection
                    
walletSocket.on("confirm_dapp_connection", () => {
    // dApp confirmed connection
})
await socket.emit("confirm_dapp_connection", { Room: room })
                    
                
                Confirms that the dApp is connected to the server and that it has received the pubkey from the wallet.
On sing_payload
                    
await 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 update
                    
socket.on("update", (id: number, status: H256 | ISubmittableResult) => {
    // Handle the update logic
})
                    
                
                
                    Receives an update for the extrinsic signed by a signer.sign
                
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
                    
await 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.
On disconnect
                    
socket.on("disconnect", () => {
    // react to the disconnection
})
                    
                
                Event handler that is fired whenever someone disconnects.