0

I am failing to connect with kukai via beacon (ghostnet), it works fine with a different wallet. "network error". Another engineer shared that there are known issues with kukai on ghostnet, is this a known problem?enter image description here

Could we get this solved with beacon itself, so kukai doesn’t require a specific treatment for ghostnet?

1 Answer 1

0

First, it's not as easy as it seems. The problem is that for all wallets except Kukai, the "location" of the wallet in terms of where the connection has to be established, is the same. But with Kukai, it is different. This is because Kukai has two deployments, one for mainnet (wallet.kukai.app), and another one for ghostnet (ghostnet.kukai.app). Those two sites are completely independent of each other. Every other wallet, Naan, Temple, AirGap, Umami, etc., only has one app, no matter if it's ghostnet or mainnet.

The way beacon works is that it first establishes a connection between dApp and wallet, then it sends the permission request.

During the first step (establishing the connection), the network (mainnet / ghostnet) that will be used later on doesn't matter. It's just establishing the connection so messages can be exchanged. Only in the second step, the permission request, the network becomes relevant because you ask for permissions on a certain network.

This flow works without any special configuration for all wallets except Kukai. For Kukai on ghostnet we have to point to a "different wallet" / location with a different URL.

Because establishing the connection happens before the permission request is sent, beacon cannot know at the time of establishing the connection if the permission request is going to be sent on mainnet or ghostnet (a dApp can choose to ask for both mainnet and ghostnet permissions at the same time with beacon, except with Kukai). This means we always default to mainnet, and in the case of Kukai, the "preferredNetwork" has to be set to switch to their ghostnet wallet.

One thing we could do is add a big console log warning if you do not set the preferredNetwork, but the permission request is sent with a network other than mainnet. This would at least send the developer to the right docs.

Another things we could do is get rid of the network inside the permission request and have the developer always set it in the constructor, but that would be a big breaking change and it would also make it less flexible regarding sending permission requests on different networks.

Second, this is a very common misconfiguration that we see dapp developers do all the time. You must set preferredNetwork to NetworkType.GHOSTNET when you initialize the DAppClient instance. Otherwise, Beacon will do the pairing with wallet.kukai.app (mainnet) instead of ghostnet.kukai.app (ghostnet).

See the advanced example in the documentation: https://docs.walletbeacon.io/getting-started/advanced-example

It would be easy to only set network on initialization, just as WalletConnect does it. I've never seen any dapp change network dynamically anyways. That would also be a quick and clean solution to issue #482.

5
  • I confirmed that I am indeed specifying the preferredNetwork as 'ghostnet' and still have the issue.new BeaconWallet({ name: 'AstroNinja NFT Collectibles', appUrl: 'localhost:3000', preferredNetwork: process.env.NEXT_PUBLIC_NETWORK, walletConnectOptions: { projectId: '97f804b46f0db632c52af0556586a5f3', relayUrl: 'wss://relay.walletconnect.com' }, featuredWallets: ['kukai', 'trust', 'temple', 'umami']
    – user9011
    Commented Jun 12, 2023 at 13:33
  • You will send a permission request for mainnet here: github.com/trilitech/sample-dapp/blob/main/packages/providers/… on ghostnet.kukai.app that is expected to fail. Mainnet is default if you don't provide any argument to requestPermissions
    – user9011
    Commented Jun 12, 2023 at 13:33
  • looks like requestPermissions takes in PermissionScope but how do I specify ghostnet?
    – user9011
    Commented Jun 12, 2023 at 13:33
  • dAppClient.requestPermissions( { type: NetworkType.MAINNET } ) - Just as you dit it here: github.com/trilitech/sample-dapp/blob/main/packages/providers/…
    – user9011
    Commented Jun 12, 2023 at 13:33
  • NetworkType.GHOSTNET should work
    – maelswarm
    Commented Jun 13, 2023 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.