> ## Documentation Index
> Fetch the complete documentation index at: https://docs.teqoin.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Contract abis

> Organize, generate, and use contract ABIs for TeQoin applications

# Contract ABIs

Application Binary Interfaces, or ABIs, describe how your app talks to a contract. Every frontend, script, indexer, and automation workflow depends on having the right ABI for the contract you call.

## What to store

For each deployed contract, keep:

* The contract name
* The deployment address
* The chain ID
* The exact ABI used by the deployed bytecode
* The commit or release that produced that deployment

## Recommended project structure

```text theme={null}
abi/
  Counter.json
  Treasury.json
deployments/
  teqoin.json
```

Example `deployments/teqoin.json`:

```json theme={null}
{
  "chainId": 420377,
  "contracts": {
    "Counter": {
      "address": "0xYourContractAddress",
      "abiFile": "abi/Counter.json"
    }
  }
}
```

## Export ABI from Hardhat

After compilation, Hardhat writes artifacts to `artifacts/contracts/...`.

You can copy the ABI from the artifact:

```bash theme={null}
cat artifacts/contracts/Counter.sol/Counter.json
```

Look for the `abi` array and save it into your app-facing ABI file.

## Export ABI from Foundry

Foundry stores compiled output in `out/`.

```bash theme={null}
cat out/Counter.sol/Counter.json
```

Again, copy the `abi` section into the file your frontend imports.

## Use an ABI in ethers

```javascript theme={null}
import { ethers } from 'ethers';
import counterAbi from './abi/Counter.json';

const provider = new ethers.JsonRpcProvider('https://rpc.teqoin.io');

const counter = new ethers.Contract(
  '0xYourContractAddress',
  counterAbi,
  provider
);
```

## ABI hygiene

Keep these rules in place:

* Regenerate the ABI every time the contract interface changes
* Do not hand-edit ABI files
* Version ABIs by release when you have multiple deployments
* Keep addresses separate from ABI definitions

## Related pages

* [/tutorials/deploy-first-contract](/tutorials/deploy-first-contract)
* [/resources/sdks-libraries](/resources/sdks-libraries)
