MakeSCQuery
Description
Make a smart contract query.
Declaration
public static void MakeSCQuery<T>(string scAddress, string methodName, UnityAction<CompleteCallback<T>> completeMethod, TypeValue[] outputType, params IBinaryType[] args) where T : IBinaryType
Parameters
Name
Description
scAddress
The address of the smart contract.
methodName
The method to call.
completeMethod
Callback to get the result of the query after finished
outputType
Type of expected result
args
The list of arguments. Can be of type: BooleanValue, BytesValue, EnumValue, MultiValue, NumericValue, OptionValue, StructValue, TokenIdentifierValue
Example
This method will querry the adder smart contract
https://github.com/multiversx/mx-reproducible-contract-build-example-sc/blob/main/adder/src/adder.rs
public class Test : MonoBehaviour
{
public void Call()
{
MultiversX.UnityTools.API.MakeSCQuery<NumericValue>("erd1qqqqqqqqqqqqqpgqmm2m825y2t9nya0yqeg3nqlh2q50e7pd0eqq98uw2e", "getSum", QueryComplete, new TypeValue[] { TypeValue.BigUintTypeValue });
}
private void QueryComplete(CompleteCallback<NumericValue> result)
{
if (result.status == OperationStatus.Success)
{
Debug.Log($"Current sum: {result.data}");
}
else
{
Debug.LogError(result.errorMessage);
}
}
}
Last updated