# Cross contract calls

{% hint style="info" %}
Before we start, you may want to check out our [Bulletin Board Example repository](https://github.com/Cardinal-Cryptography/bulletin-board-example): all the code you will find in this tutorial is there in its full form. The examples in there are not limited to cross-contract calls and cover almost every aspect of smart contract development, so we encourage you to study it in addition to reading this guide.
{% endhint %}

The ability of smart contracts to call methods of another contract is arguably one of the most powerful concepts offered by Ink!. For example, a DEX will need to call the `transfer_from` method of a PSP22 token. However, this is also a feature that requires a lot of care during implementation.

#### Basics <a href="#basics" id="basics"></a>

Ink! offers two ways of calling another contract, each with a different set of trade-offs:

* **Importing a Reference to Another Contract:**

  * **Convenience:** Using a reference to another contract is very convenient.
  * **Compiler Assistance:** The compiler can check whether the method you want to call exists and if the parameter types match.
  * **Limitations:** It doesn’t allow you to dynamically construct calls or send tokens with the call.

  **Dynamically Building a Call (using the `CallBuilder` method):**

  * **Control:** Offers a lot of control over the execution.
  * **Token Transfer:** Allows for sending tokens along with the call.
  * **Dynamic Method Selection:** Enables dynamically choosing a method to call.
  * **Compiler Limitations:** The compiler cannot assist in creating a valid call, so you need to be extra careful.

{% hint style="info" %}
While the choice of a particular method may be a matter of personal preference, we suggest using the references by default and choosing the `CallBuilder` only if you really need it.
{% endhint %}

#### The examples <a href="#the-examples" id="the-examples"></a>

In the two subsequent sections, we will use the `BulletinBoard` contract as an example. The contract allows users to post pieces of text ('bulletins') to the board and highlight selected posts. The highlighted posts are tracked by a separate contract: `HighlightedPosts`.

The split between the two contracts is pretty arbitrary and not really necessary for this logic to work. However, it serves a higher purpose of demonstrating cross-contract calls in an easy-to-understand example.


---

# Agent Instructions: 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://dev.phron.ai/build-with-phronai/smart-contracts-development/rust-contracts/cross-contract-calls.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.
