Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: docs useContractRead #1341

Merged
merged 16 commits into from
Jun 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/docs/docs/dev/hooks-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,34 @@ console.log(connectors);

[See the source file](https://github.com/FuelLabs/fuels-npm-packs/tree/main/packages/react/src/hooks/useConnectors.ts)

## `useContractRead`

Reads and calls a method from a Fuel contract, returns `<InvokeFunctions>`.


##### Reading with a Contract instance
```tsx
const { contractRead } = useContractRead({
contract: _contract,
functionName: 'get_count',
args: undefined,
});
```

##### Reading with ABI + ContractId + Provider
```tsx
const { contractRead } = useContractRead({
contract: { address, abi: countAbi, provider },
functionName: 'get_count',
args: undefined,
});
```
> For more information on our Provider, refer to our TS SDK [docs](https://docs.fuel.network/docs/fuels-ts/)

> Click [here](https://github.com/FuelLabs/fuels-wallet/blob/b5766321dbc2a5e5f17f05e0cb9a9f697f137a23/packages/e2e-contract-tests/src/contracts/contracts/factories/CustomAssetAbi__factory.ts#L16) to see an example of an ABI for a Fuel contract

[See the source file](https://github.com/FuelLabs/fuels-npm-packs/tree/main/packages/react/src/hooks/useAccount.ts)

## `useDisconnect`

Facilitates disconnection from the Fuel Wallet. It provides a function `UseMutateAsyncFunction<boolean | undefined>` to initiate disconnection.
Expand Down
Loading