> For the complete documentation index, see [llms.txt](https://calnix.gitbook.io/eth-dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://calnix.gitbook.io/eth-dev/deployment/interacting-with-external-contracts.md).

# Interacting with External Contracts

Say you want to interact with a deployed contract, but you don't have the published source code or interface to work with.

You can work with the ABI of the contract + address.

Assuming the ABI is not published, you can extract it from the website front-end:

* Dev Console -> Sources -> js bundles
* look through the js folder, the abi will be a long string in there somewhere

Once you extract the ABI:

Ensure the abi starts off in this manner: \[{....

![](/files/9pmWiCeIr8act0rSvVae)

If it starts with abi =\[.. you can drop that bit.

{% hint style="info" %}
When you compile with brownie, compiled code is placed into `build` directory as a .json file. That 10.000 lines of code is not abi, abi is the first property of that json file.
{% endhint %}

### Loading the ABI into Brownie

```python
with open("./scripts/IdleGameAbi.json") as file:
    contract_abi = json.load(file)

# contract
contract_address = "0x82a85407BD612f52577909F4A58bfC6873f14DA8"
contract = Contract.from_abi("IdleGame", contract_address, contract_abi)

```

![](/files/7zZWwAzY3ijw3YZyLJqK)

#### Some reference:

<https://ethereum.stackexchange.com/questions/114238/creating-a-contract-contrainer-with-brownie>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://calnix.gitbook.io/eth-dev/deployment/interacting-with-external-contracts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
