useScaffoldReadContract
Use this hook to read public variables and get data from read-only functions of your smart contract.
const { data: totalCounter } = useScaffoldReadContract({
contractName: "YourContract",
functionName: "userGreetingCounter",
args: ["0xd8da6bf26964af9d7eed9e03e53415d37aa96045"],
});
This example retrieves the data returned by the userGreetingCounter function of the YourContract smart contract.
Configurationโ
| Parameter | Type | Description |
|---|---|---|
| contractName | string | Name of the contract to read from. |
| functionName | string | Name of the function to call. |
| args (optional) | unknown[] | Array of arguments to pass to the function (if any). Types are inferred from the contract's function parameters. |
| blockIdentifier (optional) | BlockNumber | Block identifier to use (default: pending). |
| watch (optional) | boolean | Watches and refreshes data on new blocks. (default : true) |
| Other arguments | various | You can pass other arguments accepted by the useContractRead hook from @starknet-start/react. |
You can also pass other arguments accepted by starknet-start useReadContract.
Return Valuesโ
- The retrieved data is stored in the
dataproperty of the returned object. - The extended object includes properties inherited from the
useReadContracthook of starknet-start. You can check the useReadContract return values documentation for the types.