Hi David!
I watched the video but I still have trouble writing a C# method for ExecuteContractFunction that does the claim, specifically using pars. But I get lots of errors and I do not really know how to structure it like
public async static UniTask ExecuteContractFunction(string contractAddress,
string abi,
string functionName,
object[] args,
HexBigInteger value,
HexBigInteger gas,
HexBigInteger gasPrice)
{
string result = null;
string gasValue = gas.Value.ToString();
string gasPriceValue = gasPrice.ToString();
if (gasValue.Equals("0") || gasValue.Equals("0x0")) gasValue = "";
if (gasPriceValue.Equals("0") || gasPriceValue.Equals("0x0")) gasPriceValue = "";
try
{
#if UNITY_WEBGL
string functionArgs = JsonConvert.SerializeObject(args);
result = await Web3GL.SendContract(functionName, abi, contractAddress, functionArgs, value.Value.ToString(), gasValue, gasPriceValue);
#else
// Retrieve from address, the address used to authenticate the user.
MoralisUser user = await Moralis.GetUserAsync();
string fromAddress = user.authData[âmoralisEthâ][âidâ].ToString();
Contract contractInstance = Web3Client.Eth.GetContract(abi, contractAddress);
Function function = contractInstance.GetFunction(functionName);
if (function != null)
{
result = await function.SendTransactionAsync(fromAddress, gas, value, args);
}
#endif
}
catch (Exception exp)
{
Debug.Log($âCall to {functionName} failed due to: {exp.Message}â);
}
return result;
}
what would be a better way for me to call pars using ExecuteContractFunction because the names in the new video are different, I am not that experienced with connecting to the blockchain with Unity