Docs

Call Functions

If the functionality of your smart contract does not come under one of thirdweb's supported interfaces, use the generic Read method to retrieve the data, and store the value by awaiting the function call.

Usage

var data = await contract.Read<int>("functionName");

Configuration

type (generic type)

The type of data returned by the function call. This is used to convert the data returned by the function call into the correct type. For example, if your function returns a string, you would use string as the generic type.

functionName

The name of the function, view, mapping, variable, etc. on your smart contract.

Must be a string.

args

The arguments to the function/variable, in the same order they are on your smart contract.

If you provide too few or too many arguments, the function will throw an error.

var data = await contract.Read<int>("functionName", "arg1", "arg2", ...);