diff --git a/docs/hooks/useDeployedContractInfo.md b/docs/hooks/useDeployedContractInfo.md index d8d0808..2e4fd7a 100644 --- a/docs/hooks/useDeployedContractInfo.md +++ b/docs/hooks/useDeployedContractInfo.md @@ -7,16 +7,17 @@ sidebar_position: 5 Use this hook to fetch details about a deployed smart contract, including the ABI and address. ```ts -const { data: deployedContractData } = useDeployedContractInfo(contractName); +const { data: deployedContractData } = useDeployedContractInfo({ contractName: "YourContract" }); ``` This example retrieves the details of the deployed contract with the specified name and stores the details in the `deployedContractData` object. -## Parameters +## Configuration -| Parameter | Type | Description | -| :--------------- | :------- | :-------------------- | -| **contractName** | `string` | Name of the contract. | +| Parameter | Type | Description | +| :--------------------- | :------- | :------------------------------------------------------------------------------------------------------------------------- | +| **contractName** | `string` | Name of the contract. | +| **chainId** (optional) | `string` | Id of the chain the contract lives on. Defaults to [`targetNetworks[0].id`](/deploying/deploy-nextjs-app#--targetnetworks) | ### Return Value diff --git a/docs/hooks/useScaffoldContract.md b/docs/hooks/useScaffoldContract.md index 1848794..1c4a007 100644 --- a/docs/hooks/useScaffoldContract.md +++ b/docs/hooks/useScaffoldContract.md @@ -20,6 +20,7 @@ import { useWalletClient } from "wagmi"; const { data: walletClient } = useWalletClient(); const { data: yourContract } = useScaffoldContract({ contractName: "YourContract", + chainId: 31337, walletClient, }); const setGreeting = async () => { @@ -32,10 +33,11 @@ This example uses the `useScaffoldContract` hook to obtain a contract instance f ## Configuration -| Parameter | Type | Description | -| :-------------------------- | :----------------------------------------------------------------- | :---------------------------------------------------------------------------- | -| **contractName** | `string` | Name of the contract. | -| **walletClient** (optional) | [`WalletClient`](https://wagmi.sh/react/api/hooks/useWalletClient) | Wallet client must be passed in order to call `write` methods of the contract | +| Parameter | Type | Description | +| :-------------------------- | :----------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------- | +| **contractName** | `string` | Name of the contract. | +| **walletClient** (optional) | [`WalletClient`](https://wagmi.sh/react/api/hooks/useWalletClient) | Wallet client must be passed in order to call `write` methods of the contract | +| **chainId** (optional) | `string` | Id of the chain the contract lives on. Defaults to [`targetNetworks[0].id`](/deploying/deploy-nextjs-app#--targetnetworks) | ## Return Value diff --git a/docs/hooks/useScaffoldEventHistory.md b/docs/hooks/useScaffoldEventHistory.md index 210a850..51f90b7 100644 --- a/docs/hooks/useScaffoldEventHistory.md +++ b/docs/hooks/useScaffoldEventHistory.md @@ -38,6 +38,7 @@ This example retrieves the historical event logs for the `GreetingChange` event | **receiptData** (optional) | `boolean` | If set to true it will return the receipt data for each event (default: false). | | **watch** (optional) | `boolean` | If set to true, the events will be refetched every [`pollingInterval`](/deploying/deploy-nextjs-app#--pollinginterval) set at `scaffold.config.ts`. (default: false). | | **enabled** (optional) | `boolean` | If set to false, the hook will not fetch any data (default: true). | +| **chainId** (optional) | `string` | Id of the chain the contract lives on. Defaults to [`targetNetworks[0].id`](/deploying/deploy-nextjs-app#--targetnetworks) | ## Return Values diff --git a/docs/hooks/useScaffoldReadContract.md b/docs/hooks/useScaffoldReadContract.md index 469c5c6..e2906d3 100644 --- a/docs/hooks/useScaffoldReadContract.md +++ b/docs/hooks/useScaffoldReadContract.md @@ -18,12 +18,13 @@ This example retrieves the data returned by the `userGreetingCounter` function o ## 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 accepts any). Types are inferred from contract's function parameters | -| **watch** (optional) | `boolean` | Watches and refreshes data on new blocks. (default : `true`) | +| 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 accepts any). Types are inferred from contract's function parameters | +| **watch** (optional) | `boolean` | Watches and refreshes data on new blocks. (default : `true`) | +| **chainId** (optional) | `string` | Id of the chain the contract lives on. Defaults to [`targetNetworks[0].id`](/deploying/deploy-nextjs-app#--targetnetworks) | You can also pass other arguments accepted by [useReadContract wagmi hook](https://wagmi.sh/react/api/hooks/useReadContract#parameters). diff --git a/docs/hooks/useScaffoldWatchContractEvent.md b/docs/hooks/useScaffoldWatchContractEvent.md index 96f36d6..2f24c37 100644 --- a/docs/hooks/useScaffoldWatchContractEvent.md +++ b/docs/hooks/useScaffoldWatchContractEvent.md @@ -32,11 +32,12 @@ Due to shortcomings of some RPC providers, this hook may or may not fire events ## Configuration -| Parameter | Type | Description | -| :--------------- | :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| **contractName** | `string` | Name of the contract to read from. | -| **eventName** | `string` | Name of the event to read. | -| **onLogs** | `function` | Callback function to execute when the event is emitted. Accepts an array of `logs` that occurred during the [`pollingInterval`](/deploying/deploy-nextjs-app#--pollinginterval) set at `scaffold.config.ts`. Each array item contains an `args` property, which can be destructured to get the parameters emitted by the event. This function can customized according to your needs. | +| Parameter | Type | Description | +| :--------------------- | :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| **contractName** | `string` | Name of the contract to read from. | +| **eventName** | `string` | Name of the event to read. | +| **onLogs** | `function` | Callback function to execute when the event is emitted. Accepts an array of `logs` that occurred during the [`pollingInterval`](/deploying/deploy-nextjs-app#--pollinginterval) set at `scaffold.config.ts`. Each array item contains an `args` property, which can be destructured to get the parameters emitted by the event. This function can customized according to your needs. | +| **chainId** (optional) | `string` | Id of the chain the contract lives on. Defaults to [`targetNetworks[0].id`](/deploying/deploy-nextjs-app#--targetnetworks) | :::note diff --git a/docs/hooks/useScaffoldWriteContract.md b/docs/hooks/useScaffoldWriteContract.md index 4ab86fb..30224b3 100644 --- a/docs/hooks/useScaffoldWriteContract.md +++ b/docs/hooks/useScaffoldWriteContract.md @@ -7,7 +7,7 @@ sidebar_position: 2 Use this hook to send a transaction to your smart contract to write data or perform an action. ```ts -const { writeContractAsync: writeYourContractAsync } = useScaffoldWriteContract("YourContract"); +const { writeContractAsync: writeYourContractAsync } = useScaffoldWriteContract({ contractName: "YourContract" }); ``` The first argument is name of the contract to write to and the second argument is wagmi's `useWriteContract` hook [parameters object](https://wagmi.sh/react/api/hooks/useWriteContract#parameters). @@ -39,13 +39,14 @@ Below is the configuration for `writeContractAsync` function: ## Configuration -| Parameter | Type | Description | -| :--------------------------------- | :---------- | :------------------------------------------------------------------------------------------------------------------- | -| **functionName** | `string` | Name of the function to call. | -| **args** (optional) | `unknown[]` | Array of arguments to pass to the function (if accepts any). Types are inferred from contract's function parameters. | -| **value** (optional) | `bigint` | Amount of ETH to send with the transaction (for payable functions only). | -| **onBlockConfirmation** (optional) | `function` | Callback function to execute when the transaction is confirmed. | -| **blockConfirmations** (optional) | `number` | Number of block confirmations to wait for before considering transaction to be confirmed (default : 1). | +| Parameter | Type | Description | +| :--------------------------------- | :---------- | :------------------------------------------------------------------------------------------------------------------------- | +| **functionName** | `string` | Name of the function to call. | +| **args** (optional) | `unknown[]` | Array of arguments to pass to the function (if accepts any). Types are inferred from contract's function parameters. | +| **value** (optional) | `bigint` | Amount of ETH to send with the transaction (for payable functions only). | +| **onBlockConfirmation** (optional) | `function` | Callback function to execute when the transaction is confirmed. | +| **blockConfirmations** (optional) | `number` | Number of block confirmations to wait for before considering transaction to be confirmed (default : 1). | +| **chainId** (optional) | `string` | Id of the chain the contract lives on. Defaults to [`targetNetworks[0].id`](/deploying/deploy-nextjs-app#--targetnetworks) | You can also pass other arguments accepted by [writeContractAsync from wagmi](https://wagmi.sh/react/api/hooks/useWriteContract#mutate-async).