You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Hazim Bin Ijaz d02491f3a9 Added thirdweb TG SDK 1 month ago
..
Prefabs Added thirdweb TG SDK 1 month ago
Runtime Added thirdweb TG SDK 1 month ago
CHANGELOG.md Added thirdweb TG SDK 1 month ago
CHANGELOG.md.meta Added thirdweb TG SDK 1 month ago
LICENSE Added thirdweb TG SDK 1 month ago
LICENSE.meta Added thirdweb TG SDK 1 month ago
Prefabs.meta Added thirdweb TG SDK 1 month ago
README.md Added thirdweb TG SDK 1 month ago
README.md.meta Added thirdweb TG SDK 1 month ago
Runtime.meta Added thirdweb TG SDK 1 month ago
package.json Added thirdweb TG SDK 1 month ago
package.json.meta Added thirdweb TG SDK 1 month ago

README.md

WalletConnect Modal

Simplest and most minimal way to connect your players with WalletConnect

Supported Platforms

Prerequisites

  • Unity 2021.3 or above
  • IL2CPP code stripping level: Minimal (or lower)
  • Project created in WalletConnect Cloud

Documentation

Usage

  1. Install WalletConnectUnity Modal package. If installing as Git URL, also install UI and Core packages.

  2. Add Name (can be anything) and your Project ID to the Assets/WalletConnectUnity/Resources/WalletConnectProjectConfig asset.

  3. Drag and drop WalletConnectModal prefab from WalletConnectUnity Modal package to the first scene in your game.

  4. Open modal after initialization

    • By default Modal will initialize itself asynchronously on Awake. During initialization it will also try to connect to the last session.
    • After initialization, Modal invokes WalletConnectModal.Ready static event.
    • If Ready argument's SessionResumed is true, it means that Modal has successfully connected to the last session. In this case you don't need to open the modal. Otherwise, open the modal with WalletConnectModal.Open() static method.
private void Start()
{
    WalletConnectModal.Ready += (sender, args) =>
    {
        if (args.SessionResumed)
        {
            // Session has been resumed, proceed to the game
        }
        else
        {
            // Session hasn't been resumed

            // Define required namespaces for new session
            var requiredNamespaces = new RequiredNamespaces
            {
                {
                    "eip155", new ProposedNamespace
                    {
                        Methods = new[]
                        {
                            "eth_sendTransaction",
                            "personal_sign",
                            "eth_signTypedData"
                        },
                        Chains = new[]
                        {
                            "eip155:1"
                        },
                        Events = new[]
                        {
                            "chainChanged",
                            "accountsChanged"
                        }
                    }
                }
            };

            var connectOptions = new ConnectOptions
            {
                RequiredNamespaces = requiredNamespaces
            };

            // Open modal
            WalletConnectModal.Open(new WalletConnectModalOptions
            {
                ConnectOptions = connectOptions
            });
        }
    };
}
  1. Subscribe to ActiveSessionChanged and SessionDeleted events. It's recommended to do it in Ready event handler.
WalletConnectModal.Ready += (sender, args) =>
{
    // ....

    // Invoked after wallet connected
    WalletConnect.Instance.ActiveSessionChanged += (_, sessionStruct) =>
    {
        // Session connected/updated, proceed to the game if sessionStruct.topic is not null/empty
    };

    // Invoked after wallet disconnected
    WalletConnect.Instance.SessionDisconnected += (_, _) =>
    {
        // Session deleted, show sign in screen
    };
};

Sample