Unity

Unity version of the connect sdk

Install

see github

Instantiate a Connect Wallet

private const string API_KEY = "my_api_key";
private int _chainId = 80001;
private ConnectAdaptor _connectAuthAdaptor;
private ComethWallet _wallet;

private void Start()
{
    if (string.IsNullOrEmpty(apiKey) || chainId == 0)
    {
	Debug.LogError("Please set the apiKey and chainId serialised variables");
	return;
    }
    _connectAuthAdaptor = new ConnectAdaptor(chainId, apiKey, baseUrl);
    _wallet = string.IsNullOrEmpty(baseUrl)
	? new ComethWallet(_connectAuthAdaptor, apiKey)
	: new ComethWallet(_connectAuthAdaptor, apiKey, baseUrl);
}

Available methods

  • Create a Wallet

await _wallet.Connect()
  • Connect to Wallet

await _wallet.Connect(WALLET_ADDRESS)
  • Get Address

await _wallet.GetAddress()
  • Send transaction

var safeTxHash = await _wallet.SendTransaction(to, value, data);
  • Get Transaction Receipt

var transactionReceipt = await _wallet.Wait(safeTxHash);
  • Sign Message

var messageSigned = await _wallet.SignMessage("Hello World!");

  • Init a new Signer Request

var addSignerRequest = await connectAuthAdaptor.InitNewSignerRequest(walletAddress);
  • Get all Signer Requests

var newSignerRequests = await connectAuthAdaptor.GetNewSignerRequests();

Last updated