Skip to main content
Message signing works without the Solana extension package (xyz.dynamic.unitysdk.solana).

Sign a message

string signature = await DynamicSDK.Instance.Networks.Solana.SignMessage(
    wallet.Id, "Hello World");

Debug.Log($"Signature: {signature}");

Complete example

using DynamicSDK.Core;
using UnityEngine;
using System.Linq;

public class SolanaSigningManager : MonoBehaviour
{
    private BaseWallet _solWallet;
    
    private void Start()
    {
        _solWallet = DynamicSDK.Instance.Wallets.UserWallets
            .FirstOrDefault(w => w.Chain.ToUpper() == "SOL");
    }
    
    public async void SignMessage()
    {
        if (_solWallet == null)
        {
            Debug.LogError("No Solana wallet available");
            return;
        }
        
        string message = "Sign this message to verify your identity";
        
        try
        {
            string signature = await DynamicSDK.Instance.Networks.Solana.SignMessage(
                _solWallet.Id, message);
            
            Debug.Log($"Message: {message}");
            Debug.Log($"Signature: {signature}");
            Debug.Log($"Signer: {_solWallet.Address}");
        }
        catch (System.Exception ex)
        {
            Debug.LogError($"Signing failed: {ex.Message}");
        }
    }
    
    public async void SignTimestampedMessage()
    {
        if (_solWallet == null)
        {
            Debug.LogError("No Solana wallet available");
            return;
        }
        
        // Include timestamp for replay protection
        long timestamp = System.DateTimeOffset.UtcNow.ToUnixTimeSeconds();
        string message = $"Sign in at {timestamp}";
        
        string signature = await DynamicSDK.Instance.Networks.Solana.SignMessage(
            _solWallet.Id, message);
        
        Debug.Log($"Timestamped signature: {signature}");
    }
}

Next steps