chainsafe-test/Assets/Web3Unity/Scripts/Prefabs/WebGL/WebGLSendTransactionExample.cs
2023-11-28 11:36:18 +05:30

31 lines
847 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_WEBGL
public class WebGLSendTransactionExample : MonoBehaviour
{
async public void OnSendTransaction()
{
// account to send to
string to = "0x428066dd8A212104Bc9240dCe3cdeA3D3A0f7979";
// amount in wei to send
string value = "12300000000000000";
// gas limit OPTIONAL
string gasLimit = "";
// gas price OPTIONAL
string gasPrice = "";
// connects to user's browser wallet (metamask) to send a transaction
try
{
string response = await Web3GL.SendTransaction(to, value, gasLimit, gasPrice);
Debug.Log(response);
}
catch (Exception e)
{
Debug.LogException(e, this);
}
}
}
#endif