MultiversX Unity Tools
  • Overview
  • Demo App
  • Setup Guide
  • Quick Start
  • Video Tutorials
  • Complete API
    • CallSCMethod
    • CheckTransactionStatus
    • Connect
    • DeepLinkLogin
    • Disconnect
    • GetApiProvider
    • GetConnectedAccount
    • GetNetworkConfig
    • GetRequest
    • IsWalletConnected
    • LoadAllTokens
    • LoadImage
    • LoadNetworkConfig
    • LoadWalletNFTs
    • MakeSCQuery
    • PostRequest
    • SendEGLDTransaction
    • SendESDTTransaction
    • SendMultipleTrasactions
    • SendNFT
    • SignMessage
    • SignMultipleTrasactions
    • RefreshAccount
  • Releases
Powered by GitBook
On this page
  • Description
  • Declaration
  • Parameters
  • Example
  1. Complete API

MakeSCQuery

PreviousLoadWalletNFTsNextPostRequest

Last updated 1 year ago

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

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);
        }
    }
}
https://github.com/multiversx/mx-reproducible-contract-build-example-sc/blob/main/adder/src/adder.rs