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.


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


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.


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

Must be a string.


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", ...);