QR Image Not Loading
After setting up Web3Modal by following the documentation, no QR codes are loading for me to scan when testing in the editor.
Unity Version: 2022.3.11f1 Web3Modal Version: 0.3.1
There doesn't seem to be any errors and the logs seem to indicate I established a connection.
Connector.Connect
UnityEngine.Debug:Log (object)
WalletConnect.Web3Modal.Connector:Connect () (at ./Library/PackageCache/[email protected]/Runtime/Connectors/Connector.cs:62)
Got connection
UnityEngine.Debug:Log (object)
WalletConnect.Web3Modal.Connector:Connect () (at ./Library/PackageCache/[email protected]/Runtime/Connectors/Connector.cs:68)
Hello,
It appears the app did not receive a response from the WalletConnect relay. Could you please answer a few questions to help me better understand the situation?
- What's your operating system?
- Do you have VPN/Proxy enabled?
- Can you access https://walletconnect.com/ in your browser without VPN/Proxy in your network?
- Have you tried connecting on another network?
- What target platform is selected in the build settings?
- Windows 10
- No VPN/Proxy
- Yes I can access walletconnect.com
- I tried 2 different Wifi networks that I have
- Build settings are for Windows (Intel 64-bit Architecture)
I found more logs when I enabled logging in the config, this comes after the logs I sent above. (I removed the params in-case my app id is in there)
[Relayer] Checking for established connection
[Relayer] Sending request through provider
[JsonRpcProvider] Checking if connected
[JsonRpcProvider] Sending request irn_subscribe with data {"method":"irn_subscribe","params":{}
[Relayer] Checking for established connection
[Relayer] Sending request through provider
[JsonRpcProvider] Checking if connected
[JsonRpcProvider] Sending request irn_publish with data {"method":"irn_publish","params":{}
Sometimes if I try to reload a QR after this I get a couple expired topic logs, then an unsubscribe log:
Expired topic topic:1557bade5ac4527512223d3b6cfdfb09eae1a38ffad2196223153f7ba7dc4c68
Expired topic id:74258315530174
[JsonRpcProvider] Sending request irn_unsubscribe with data {"method":"irn_unsubscribe","params":{}
I just tried a build and it seems to be the same issue, so not just an editor problem.
Though when I ran the build I did notice this warning about an uncompiled Assembly Definition File. This might be the culprit since I think its a barcode library. There doesn't seem to be any scripts alongside the dll.
Assembly for Assembly Definition File 'Packages/com.walletconnect.core/Runtime/External/ZXing/ZXing.asmdef' will not be compiled, because it has no scripts associated with it.
@WoodsFiend thank you providing more information 🙏
It looks like the problem is with the ZXing library used for generating QR code images. I'm looking into it. Meanwhile, can you confirm if the "Copy link" button on the screen where the QR code should appear is working for you? Does it copy the WalletConnect connection URI?
@skibitsky Yes it does copy the WalletConnect connection URI
Hey @WoodsFiend,
Sorry for the delay. I have fixed the warning in the recent release. Could you please upgrade Web3Modal to v0.3.2 and check if the issue persists?
I also have this issue. "com.walletconnect.web3modal": "0.4.1"
@mrsaleh do you use linear or gamma color space?
@skibitsky Linear color space. I changed it to gamma, still the same issue.
I just manually generated QRCode , and it worked , I also achieved to connect my trust wallet by scanning the QRCode. So I'm pretty sure QRCode generation is the issue.
`[SerializeField] private Image _qrCode;
private static Color32[] Encode(string textForEncoding, int width, int height) {
var writer = new BarcodeWriter {
Format = BarcodeFormat.QR_CODE,
Options = new QrCodeEncodingOptions {
Height = height,
Width = width
}
};
return writer.Write(textForEncoding);
}
public Texture2D generateQR(string text) {
var encoded = new Texture2D (256, 256);
var color32 = Encode(text, encoded.width, encoded.height);
encoded.SetPixels32(color32);
encoded.Apply();
return encoded;
}
public async UniTask Start(){
// Initialize singleton
await WalletConnectUnity.Core.WalletConnect.Instance.InitializeAsync();
// Or handle instancing manually
var walletConnectUnity = new WalletConnectUnity.Core.WalletConnect();
await walletConnectUnity.InitializeAsync();
var dappConnectOptions = new ConnectOptions()
{
RequiredNamespaces = new RequiredNamespaces().WithProposedNamespace("eip155", new ProposedNamespace(){
Methods = new[]
{
"eth_sendTransaction",
"eth_signTransaction",
"eth_sign",
"personal_sign",
"eth_signTypedData",
},
Chains = new[]
{
"eip155:1"
},
Events = new[]
{
"chainChanged",
"accountsChanged",
}
})
};
// Try resume last session
var sessionResumed = await WalletConnectUnity.Core.WalletConnect.Instance.TryResumeSessionAsync();
if (!sessionResumed)
{
var connectedData = await WalletConnectUnity.Core.WalletConnect.Instance.ConnectAsync(dappConnectOptions);
Debug.Log("Generating qr code!");
// Create QR code texture
// var texture = WalletConnectUnity.Core.Utils.QRCode.EncodeTexture(connectedData.Uri);
Debug.Log(connectedData.Uri);
Texture2D texture = generateQR(connectedData.Uri);
Debug.Log("QR code generated!");
Debug.Log(texture);
_qrCode.sprite = Sprite.Create(texture,new Rect(0,0,texture.width,texture.height),new Vector2(0.5f,0.5f));
// ... Display QR code texture
// Wait for wallet approval
var res = await connectedData.Approval;
Debug.Log($"wallet address: {res.Self.PublicKey}");
}else{
var res = WalletConnectUnity.Core.WalletConnect.Instance.ActiveSession;
Debug.Log($"wallet address: {res.Self.PublicKey}");
Debug.Log($"wallet address: {res.CurrentAddress("eip155:1").Address}");
}
}`
@skibitsky I opened a pull request for this https://github.com/WalletConnect/Web3ModalUnity/pull/16
Apparently it was the QRCode generator library issue. I will also report the issue to the library repository. Maybe in the future we can get back to higher resolution.
Hey @mrsaleh,
Thank you for this!
Could you please provide more details about your issue?
- What operating system are you using?
- On which platform does the issue occur (e.g., Editor, Windows 11 Mono, Android 14 IL2CPP, etc.)?
- Are there any exceptions or error messages logged?
Hey @mrsaleh @WoodsFiend,
Could you please upgrade to v0.4.2 and check if that solves the issue?