Skip to main content

Calling Contract Functions

Read data and make transactions on your contract from the connected wallet.

Read Contract Data

Use the name of the function, view, or mapping, and provide any required arguments.

const { contract } = useContract("{{contract_address}}");
const { data: myData, isLoading } = useContractRead(contract, "myFunction");

Write Transactions

Transactions are made using the connected wallet (or the wallet you instantiated the SDK with).

const { contract } = useContract("{{contract_address}}");
const { mutateAsync: myFunctionAsync } = useContractWrite(contract, "myFunction");
const tx = await myFunctionAsync(["argument1", "argument2"]) // Call the function