> For the complete documentation index, see [llms.txt](https://lunes-labs.gitbook.io/dao-lunes-labs-pt/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lunes-labs.gitbook.io/dao-lunes-labs-pt/developers/para-desenvolvedores/smart-contract-ink-4.x/frontend-development/hooks/contracts/usecontract.md).

# useContract

This hook is the foundation for many other hooks in **useink**. It returns a `ChainContract<T>` type and will automatically set the RPC url for the chain you specify.

### Usage[​](https://use.ink/frontend/react/hooks/contracts/use-contract#usage) <a href="#usage" id="usage"></a>

```javascript
import { useContract } from 'useink'

const CONTRACT_ADDRESS = '..'
const ALEPH_CONTRACT_ADDRESS = '..'

export const MyContractView: React.FC = () => {
  // The default chain will be used if you omit chainId as the third argument
  // The default chain is the first item in the chain config for UseInkProvider
  const contract = useContract(CONTRACT_ADDRESS, metadata)
  const alephContract = useContract(ALEPH_CONTRACT_ADDRESS, metadata, 'aleph')

  // use with other hooks...
  // e.g. useCall, useCallSubscription, useTx, etc

  return null
}
```

### Return Value[​](https://use.ink/frontend/react/hooks/contracts/use-contract#return-value) <a href="#return-value" id="return-value"></a>

```javascript
{
  // A contract object that contains metadata, and an api client set with a specific RPC url
  contract: ChainContract<T>, 
  // A strongly typed chain name found in `useink/chains`
  chainId: ChainId,
} | undefined
```

<br>
