DynamicSDKManager.To use it, either drag the
DynamicSDKManager Prefab (located under /Runtime/Prefabs in the package) into your scene, or create an empty GameObject and add the DynamicSDKManager script manually.
Although the SDK is initialized automatically in Awake(), it is recommended that you explicitly call:
DynamicSDKManager.Instance.Initialize();
If the SDK is already initialized, a warning message will be displayed instead of re-initializing.
Interaction with the SDK
The SDK communicates by sending messages to the WebView and then subscribing to messages sent back from the WebView.The general flow is:
- You subscribe to an event representing an action of the SDK.
- You trigger an action by calling a method.
Connecting and Disconnecting the Wallet
To connect a wallet, call:DynamicSDKManager.Instance.ConnectWallet();
To disconnect the wallet, call:
DynamicSDKManager.Instance.DisconnectWallet();
Before calling these, ensure that you subscribe to the following events:
DynamicSDKManager.OnWalletConnected— triggered after a successful wallet connection. Provides the wallet address as astring.DynamicSDKManager.OnWalletDisconnected— triggered when the wallet is disconnected. This event provides no parameters.
Signing Messages
To sign a message, call:DynamicSDKManager.Instance.SignMessage(message, isSuiTransaction);
message— the string you want to signisSuiTransaction(optional) — set this totrueif signing a base64-encoded SUI transaction.
In SUI, signatures differ when signing plain strings versus base64-encoded transactions.
DynamicSDKManager.OnMessageSigned— returns the signature string for the provided message.
Sending Transactions
Currently, the SDK supports sending payable transactions for both the EVM and SUI ecosystems. To send a transaction, call:DynamicSDKManager.Instance.SendTransaction(to, value, data, network);
to— recipient addressvalue— amount of value to senddata(optional) — additional data for the transactionnetwork(optional) — choosemainnetortestnet. Defaults tomainnet.
DynamicSDKManager.OnTransactionReceived— triggered when the transaction has been executed.
It provides aTransactionReceiptobject with the following fields:TransactionHash— hash of the transactionTransactionSignature— signature of the transaction (SUI only)TransactionBytes— base64 representation of the transaction (SUI only)
Opening the Profile
To open the Dynamic Widget (where the user can view their private key, balances, network selection, and more), call:DynamicSDKManager.Instance.OpenProfile();