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

# Cross-Contract Calls

> Contract can interact with other contracts on the network

export const Github = ({url, start, end, fname, withSourceLink = true}) => {
  const [code, setCode] = useState(null);
  function toRaw(ref) {
    const fullUrl = ref.slice(ref.indexOf('https'));
    const [url] = fullUrl.split('#');
    const [org, repo, , branch, ...pathSeg] = new URL(url).pathname.split('/').slice(1);
    return `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${pathSeg.join('/')}`;
  }
  async function fetchCode(url, fromLine, toLine) {
    let res;
    if (typeof window !== 'undefined') {
      const validUntil = localStorage.getItem(`${url}-until`);
      if (validUntil && Number(validUntil) > Date.now()) {
        res = localStorage.getItem(url);
      }
    }
    if (!res) {
      try {
        res = await (await fetch(url)).text();
        if (typeof window !== 'undefined') {
          localStorage.setItem(url, res);
          localStorage.setItem(`${url}-until`, String(Date.now() + 60000));
        }
      } catch {
        return 'Error fetching code, please try reloading';
      }
    }
    let body = res.split('\n');
    const from = fromLine ? Number(fromLine) - 1 : 0;
    const to = toLine ? Number(toLine) : body.length;
    body = body.slice(from, to);
    const precedingSpace = body.reduce((prev, line) => {
      if (line.length === 0) return prev;
      const spaces = line.match(/^\s+/);
      if (spaces) return Math.min(prev, spaces[0].length);
      return 0;
    }, Infinity);
    return body.map(line => line.slice(precedingSpace === Infinity ? 0 : precedingSpace)).join('\n');
  }
  function buildSourceUrl(url, start, end) {
    const base = url.split('#')[0];
    if (start && end) return `${base}#L${start}-L${end}`;
    if (start) return `${base}#L${start}`;
    return base;
  }
  useEffect(() => {
    const rawUrl = toRaw(url);
    fetchCode(rawUrl, start, end).then(res => setCode(res));
  }, [url, start, end]);
  const sourceUrl = buildSourceUrl(url, start, end);
  const startLine = start ? Number(start) : 1;
  const fileName = fname ?? sourceUrl.split('/').pop();
  return <div className="rounded-[0.625rem] border border-[#d0d7de] dark:border-[#30363d] overflow-hidden my-5 text-[0.8125rem] font-mono shadow-sm dark:shadow-[0_4px_24px_rgba(0,0,0,0.18)]">

      {}
      <div className="flex items-center justify-between py-2 px-[0.875rem] bg-[#f6f8fa] dark:bg-[#161b22] border-b border-[#d0d7de] dark:border-[#30363d]">
        <div className="flex items-center gap-2 text-[#656d76] dark:text-[#8b949e]">
          <svg width="15" height="15" viewBox="0 0 24 24" fill="currentColor">
            <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" />
          </svg>
          <span className="text-xs font-medium text-[#1f2328] dark:text-[#e6edf3]">
            {fileName}
          </span>
        </div>
        {start && end && <span className="text-[0.6875rem] text-[#656d76] dark:text-[#8b949e] bg-[#eaeef2] dark:bg-[#21262d] border border-[#d0d7de] dark:border-[#30363d] rounded-full py-0.5 px-2">
            Lines {start}–{end}
          </span>}
      </div>

      {}
      <div className="overflow-auto max-h-[480px] bg-white dark:bg-[#0d1117] [&_tr]:border-b-0 [&_td]:border-b-0">
        {code === null ? <div className="py-5 px-4 text-xs text-[#656d76] dark:text-[#6e7681]">
            Loading...
          </div> : <table className="w-full border-collapse leading-[1.6]">
            <tbody>
              {code.split('\n').map((line, i) => <tr key={i} className="align-top border-0">
                  <td style={{
    minWidth: '60px'
  }} className="select-none pl-2 pr-3 text-right text-[0.7rem] text-[#8c959f] dark:text-[#3d444d] w-[1%] whitespace-nowrap border-r border-0 border-r-[#d0d7de] dark:border-r-[#21262d]">
                    {startLine + i}
                  </td>
                  <td className="pl-4 pr-6 text-[0.8125rem] text-[#1f2328] dark:text-[#e6edf3] whitespace-pre">
                    {line || ' '}
                  </td>
                </tr>)}
            </tbody>
          </table>}
      </div>

      {}
      {withSourceLink && <div className="flex justify-end py-1.5 px-[0.875rem] bg-[#f6f8fa] dark:bg-[#161b22] border-t border-[#d0d7de] dark:border-[#21262d]">
          <a href={sourceUrl} target="_blank" rel="noreferrer noopener" className="text-[0.6875rem] font-medium text-[#656d76] dark:text-[#8b949e] no-underline flex items-center gap-[0.3rem] hover:text-[#1f2328] dark:hover:text-[#e6edf3] transition-colors">
            View on GitHub
            <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
              <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" />
              <polyline points="15 3 21 3 21 9" />
              <line x1="10" y1="14" x2="21" y2="3" />
            </svg>
          </a>
        </div>}
    </div>;
};

NEAR contracts can interact with other deployed contracts, querying information and executing functions on them through cross-contract calls.

Since NEAR is a sharded blockchain, its cross-contract calls behave differently than in other chains. In NEAR, cross-contract calls are **asynchronous** and **independent**.

<Tip>
  **Asynchronous**
  The **calling function** and the **callback** execute in **different blocks** (typically 1-2 blocks apart). During this time, the contract remains active and can receive other calls.
</Tip>

<Tip>
  **Independent**

  Each function — the one making the call, the external function, and the callback — executes in its own context. If the external call fails, the calling function has already completed successfully; there's no automatic rollback. You must handle failures explicitly in the callback.
</Tip>

***

## Snippet: Querying Information

While making your contract, it is likely that you will want to query information from another contract. Below, you can see a basic example in which we query the greeting message from our [Hello NEAR](../quickstart) example.

<Tabs>
  <Tab title="🦀 Rust">
    <Tabs>
      <Tab title="low_level.rs">
        <Github fname="low_level.rs" language="rust" url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-simple-rs/src/low_level.rs" start="7" end="39" />
      </Tab>

      <Tab title="high_level.rs">
        <Github fname="high_level.rs" language="rust" url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-simple-rs/src/high_level.rs" start="8" end="37" />

        The high level API makes use of the interface defined in the [ext\_contract.rs](https://github.com/near-examples/cross-contract-calls/blob/main/contract-simple-rs/src/external_contract.rs)
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="🌐 JavaScript">
    <Github fname="contract.ts" language="js" url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-simple-ts/src/contract.ts" start="18" end="52" />
  </Tab>

  <Tab title="🐍 Python">
    ```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    from near_sdk_py import call, view, Contract, callback, PromiseResult, CrossContract, init

    class CrossContractExample(Contract):
        # Contract we want to interact with
        hello_contract = "hello-near.testnet"
            
        @init
        def new(self):
            """Initialize the contract"""
            # Any initialization logic goes here
            pass
            
        @view
        def query_greeting_info(self):
            """View function showing how to make a cross-contract call"""
            # Create a reference to the Hello NEAR contract
            # This is a simple call that will execute in the current transaction
            hello = CrossContract(self.hello_contract)
            return hello.call("get_greeting").value()
        
        @call
        def query_greeting(self):
            """Calls Hello NEAR contract to get the greeting with a callback"""
            # Create a reference to the Hello NEAR contract
            hello = CrossContract(self.hello_contract)
            
            # Call get_greeting and chain a callback
            # The Promise API handles serialization and callback chaining
            promise = hello.call("get_greeting").then("query_greeting_callback")
            
            return promise.value()
        
        @callback
        def query_greeting_callback(self, result: PromiseResult):
            """Processes the greeting result from Hello NEAR contract"""
            # The @callback decorator automatically parses the promise result
            # result will have a data property and a success boolean
            if not result.success:
                return {"success": False, "message": "Failed to get greeting"}
                
            return {
                "success": True,
                "greeting": result.data,
                "message": f"Successfully got greeting: {result.data}"
            }
    ```
  </Tab>

  <Tab title="🐹 GO">
    <Github fname="main.go" language="go" url="https://github.com/Emir-Asanov/near-go-examples/blob/example-release-1/cross-contract/main.go" start="19" end="52" />
  </Tab>
</Tabs>

***

## Snippet: Sending Information

Calling another contract passing information is also a common scenario. Below you can see a function that interacts with the [Hello NEAR](../quickstart) example to change its greeting message.

<Tabs>
  <Tab title="🦀 Rust">
    <Tabs>
      <Tab title="low_level.rs">
        <Github fname="low_level.rs" language="rust" url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-simple-rs/src/low_level.rs" start="41" end="72" />
      </Tab>

      <Tab title="high_level.rs">
        <Github fname="high_level.rs" language="rust" url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-simple-rs/src/high_level.rs" start="39" end="66" />

        The high level API makes use of the interface defined in the [ext\_contract.rs](https://github.com/near-examples/cross-contract-calls/blob/main/contract-simple-rs/src/external_contract.rs)
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="🌐 JavaScript">
    <Github fname="contract.ts" language="js" url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-simple-ts/src/contract.ts" start="54" end="87" />
  </Tab>

  <Tab title="🐍 Python">
    ```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    from near_sdk_py import call, Contract, callback, PromiseResult, CrossContract

    class CrossContractExample(Contract):
        # Contract we want to interact with
        hello_contract = "hello-near.testnet"
            
        @call
        def change_greeting(self, new_greeting):
            """Changes the greeting on the Hello NEAR contract"""
            # Create a reference to the Hello NEAR contract
            hello = CrossContract(self.hello_contract)
            
            # Create a promise to call set_greeting with the new greeting
            # Pass context data to the callback directly as kwargs
            promise = hello.call(
                "set_greeting", 
                message=new_greeting
            ).then(
                "change_greeting_callback",
                original_greeting=new_greeting  # Additional context passed to callback
            )
            
            return promise.value()
        
        @callback
        def change_greeting_callback(self, result: PromiseResult, original_greeting):
            """Processes the result of set_greeting"""
            # The original_greeting parameter is passed from the change_greeting method
            if not result.success:
                return {
                    "success": False, 
                    "message": f"Failed to set greeting to '{original_greeting}'"
                }
                
            return {
                "success": True,
                "message": f"Successfully set greeting to '{original_greeting}'",
                "result": result.data
            }
    ```
  </Tab>

  <Tab title="🐹 GO">
    <Github fname="main.go" language="go" url="https://github.com/Emir-Asanov/near-go-examples/blob/example-release-1/cross-contract/main.go" start="54" end="76" />
  </Tab>
</Tabs>

***

## Promises

Cross-contract calls work by creating two promises in the network:

1. A promise to execute code in the external contract - `Promise.create`
2. **Optional**: A promise to call another function with the result - `Promise.then`

Both promises will contain the following information:

* The **address** of the contract you want to interact with
* The **function** that you want to execute
* The arguments to pass to the function
* The amount of **GAS** to use (deducted from the **attached Gas**)
* The NEAR **deposit** to attach (deducted from **your contract's balance**)

<Tip>
  The callback can be made to **any** contract. Meaning that the result could potentially be handled by another contract
</Tip>

***

## Creating a Cross Contract Call

To create a cross-contract call with a callback, create two promises and use the `.then` method to link them:

<Tabs>
  <Tab title="🦀 Rust">
    <Tabs>
      <Tab title="High Level API">
        ```rust theme={"theme":{"light":"github-light","dark":"github-dark"}}
        #[ext_contract(external_trait)]
        trait Contract {
            fn function_name(&self, param1: T, param2: T) -> T;
        }

        external_trait::ext("external_address")
        .with_attached_deposit(DEPOSIT)
        .with_static_gas(GAS)
        .function_name(arguments)
        .then(
        // this is the callback
        Self::ext(env::current_account_id())
        .with_attached_deposit(DEPOSIT)
        .with_static_gas(GAS)
        .callback_name(arguments)
        );

        ```
      </Tab>

      <Tab title="Low Level API">
        ```rust theme={"theme":{"light":"github-light","dark":"github-dark"}}
        let arguments = json!({ "foo": "bar" })
            .to_string()
            .into_bytes();

        let promise = Promise::new("external_address").function_call(
            "function_name".to_owned(),
            arguments,
            DEPOSIT,
            GAS
        );

        promise.then(
            // Create a promise to callback query_greeting_callback
            Self::ext(env::current_account_id())
                .with_static_gas(GAS)
                .callback_name(),
        );
        ```
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="🌐 JavaScript">
    ```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
    NearPromise.new("external_address").functionCall("function_name", JSON.stringify(arguments), DEPOSIT, GAS)
    .then(
      // this function is the callback
      NearPromise.new(near.currentAccountId()).functionCall("callback_name", JSON.stringify(arguments), DEPOSIT, GAS)
    );
    ```
  </Tab>

  <Tab title="🐹 GO">
    <Github fname="main.go" language="go" url="https://github.com/Emir-Asanov/near-go-examples/blob/example-release-1/cross-contract/main.go" start="187" end="202" />

    <Note>
      In Go, `.Then()` works differently from Rust/JS. Instead of receiving a second promise object, it takes the callback method name as a **snake\_case string** — the SDK automatically routes the callback to the current contract. You do not construct a second promise manually.
    </Note>
  </Tab>
</Tabs>

<Accordion title="Concatenating Promises">
  ✅ You can concatenate promises: `P1.then(P2).then(P3)`: `P1` executes, then `P2` executes with the result of `P1`, then `P3` executes with the result of `P2`

  ✅ You can join promises: `(P1.and(P2)).then(P3)`: `P1` and `P2` execute in parallel, after they finish `P3` will execute and have access to **both their results**

  ⛔ You cannot **return** a joint promise without a callback: `return P1.and(P2)` is invalid, you need to add a `.then()`

  ⛔ You cannot join promises within a `then`: `P1.then(P2.join([P3]))` is invalid

  ⛔ You cannot use a `then` within a `then`: `P1.then(P2.then(P3))` is invalid
</Accordion>

<Info>
  If a function returns a promise, then it will delegate the return value and status of transaction execution, but if you return a value or nothing, then the `Promise` result will not influence the transaction status
</Info>

<Warning>
  The Promises you are creating will **not execute immediately**. In fact, they will be queued in the network an:

  * The cross-contract call will execute 1 or 2 blocks after your function finishes **correctly**.
</Warning>

***

## Callback Function

If your function finishes correctly, then eventually your callback function will execute. This will happen whether the **external contract fails or not**.

In the callback function you will have access to the result, which will contain the status of the external function (if it worked or not), and the values in case of success.

<Tabs>
  <Tab title="🦀 Rust">
    <Github fname="high_level.rs" language="rust" url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-simple-rs/src/high_level.rs" start="23" end="37" />
  </Tab>

  <Tab title="🌐 JavaScript">
    <Github fname="contract.ts" language="js" url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-simple-ts/src/contract.ts" start="42" end="53" />
  </Tab>

  <Tab title="🐍 Python">
    ```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    from near_sdk_py import callback, PromiseResult, Contract

    class CrossContractExample(Contract):
        @callback
        def query_greeting_callback(self, result: PromiseResult, additional_context=None):
            """
            Process the result of a cross-contract call.
            The @callback decorator automatically:
            1. Reads the promise result data
            2. Handles serialization/deserialization 
            3. Provides proper error handling
            
            Parameters:
            - result: The PromiseResult object with status and data
            - additional_context: Optional context passed from the calling function
            """
            if not result.success:
                # This means the external call failed or returned nothing
                return {
                    "success": False, 
                    "message": "Failed to get greeting",
                    "context": additional_context
                }
                
            # Process successful result
            return {
                "success": True,
                "greeting": result.data,
                "message": f"Successfully got greeting: {result.data}",
                "context": additional_context
            }
    ```
  </Tab>

  <Tab title="🐹 GO">
    <Github fname="main.go" language="go" url="https://github.com/Emir-Asanov/near-go-examples/blob/example-release-1/cross-contract/main.go" start="101" end="112" />
  </Tab>
</Tabs>

<Info>
  **Callback with always execute**

  We repeat, if your function finishes correctly, then your callback will **always execute**. This will happen no matter if the external function finished correctly or not
</Info>

<Warning>
  Always make sure to have enough Gas for your callback function to execute
</Warning>

<Tip>
  Remember to mark your callback function as private using macros/decorators, so it can only be called by the contract itself
</Tip>

### What happens if the function I call fails?

If the external function fails (i.e. it panics), then your callback will be **executed anyway**. Here you need to **manually rollback** any changes made in your
contract during the original call. Particularly:

1. **Refund the predecessor** if needed: If the contract attached NEAR to the call, the funds are now back in **the contract's account**
2. **Revert any state changes**: If the original function made any state changes (i.e. changed or stored data), you need to manually roll them back. **They won't revert automatically**

<Warning>
  If your original function finishes correctly then the callback executes **even if the external function panics**. Your state will **not** rollback automatically,
  and `$NEAR` will **not** be returned to the signer automatically. Always make sure to check in the callback if the external function failed, and manually rollback any
  operation if necessary.
</Warning>

***

## Calling Multiple Functions on the Same Contract

You can call multiple functions in the same external contract, which is known as a **batch call**.

An important property of batch calls is that they **act as a unit**: they execute in the same [receipt](/protocol/transactions/transaction-execution#receipts--finality), and if **any function fails**, then they **all get reverted**.

<Tabs>
  <Tab title="🦀 Rust">
    <Github fname="lib.ts" language="rust" url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-advanced-rs/src/batch_actions.rs" start="8" end="20" />
  </Tab>

  <Tab title="🌐 JavaScript">
    <Github fname="batch_actions" language="js" url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-advanced-ts/src/internal/batch_actions.ts" start="5" end="17" />
  </Tab>

  <Tab title="🐍 Python">
    ```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    from near_sdk_py import call, Context, Contract, callback, PromiseResult, ONE_TGAS, CrossContract, init

    class BatchCallsExample(Contract):
        # Contract we want to interact with
        hello_contract = "hello-near.testnet"
        
        @init
        def new(self):
            """Initialize the contract"""
            pass
            
        @call
        def call_multiple_methods(self, greeting1, greeting2):
            """Call multiple methods on the same contract in a batch"""
            # Create a contract instance
            hello = CrossContract(self.hello_contract)
            
            # Create a batch for the hello contract
            batch = hello.batch()
            
            # Add function calls to the batch
            batch.function_call("set_greeting", {"message": greeting1})
            batch.function_call("another_method", {"arg1": greeting2})
            
            # Add a callback to process the result
            promise = batch.then(Context.current_account_id()).function_call(
                "batch_callback", 
                {"original_data": [greeting1, greeting2]},
                gas=10 * ONE_TGAS
            )
            
            return promise.value()
            
        @callback
        def batch_callback(self, result: PromiseResult, original_data=None):
            """Process batch result - only gets the result of the last operation"""
            return {
                "success": result.success,
                "result": result.data,
                "original_data": original_data
            }
    ```
  </Tab>

  <Tab title="🐹 GO">
    <Github fname="main.go" language="go" url="https://github.com/Emir-Asanov/near-go-examples/blob/example-release-1/cross-contract/main.go" start="114" end="148" />
  </Tab>
</Tabs>

<Tip>
  Callbacks only have access to the result of the **last function** in a batch call
</Tip>

***

## Calling Multiple Functions on Different Contracts

You can also call multiple functions in **different contracts**. These functions will be executed in parallel, and do not impact each other. This means that, if one fails, the others **will execute, and NOT be reverted**.

<Tabs>
  <Tab title="🦀 Rust">
    <Github fname="lib.rs" language="rust" url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-advanced-rs/src/multiple_contracts.rs" start="17" end="55" />
  </Tab>

  <Tab title="🌐 JavaScript">
    <Github fname="lib.ts" language="js" url="https://github.com/near-examples/cross-contract-calls/blob/main/contract-advanced-ts/src/internal/multiple_contracts.ts" start="6" end="21" />
  </Tab>

  <Tab title="🐍 Python">
    ```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    from near_sdk_py import call, Contract, multi_callback, PromiseResult, CrossContract, init

    class MultiContractExample(Contract):
        # Contract addresses we want to interact with
        contract_a = "contract-a.testnet"
        contract_b = "contract-b.testnet"
        
        @init
        def new(self):
            """Initialize the contract"""
            pass
            
        @call
        def call_multiple_contracts(self):
            """Calls multiple different contracts in parallel"""
            # Create promises for each contract
            contract_a = CrossContract(self.contract_a)
            promise_a = contract_a.call("method_a")
            
            contract_b = CrossContract(self.contract_b)  
            promise_b = contract_b.call("method_b")
            
            # Join the promises and add a callback
            # The first promise's join method can combine multiple promises
            combined_promise = promise_a.join(
                [promise_b],
                "multi_contract_callback",
                contract_ids=[self.contract_a, self.contract_b]  # Context data
            )
            
            return combined_promise.value()
            
        @multi_callback
        def multi_contract_callback(self, results, contract_ids=None):
            """Process results from multiple contracts"""
            # results is an array containing all promise results in order
            return {
                "contract_a": {
                    "id": contract_ids[0],
                    "result": results[0].data,
                    "success": results[0].success
                },
                "contract_b": {
                    "id": contract_ids[1],
                    "result": results[1].data,
                    "success": results[1].success
                },
                "success": all(result.success for result in results)
            }
    ```
  </Tab>

  <Tab title="🐹 GO">
    <Github fname="main.go" language="go" url="https://github.com/Emir-Asanov/near-go-examples/blob/example-release-1/cross-contract/main.go" start="150" end="183" />
  </Tab>
</Tabs>

<Tip>
  Callbacks have access to the result of **all functions** in a parallel call
</Tip>

***

## Security Concerns

While writing cross-contract calls there is a significant aspect to keep in mind: all the calls are **independent** and **asynchronous**. In other words:

* The function in which you make the call and function for the callback are **independent**.
* There is a **delay between the call and the callback**, in which people can still interact with the contract

This has important implications on how you should handle the callbacks. Particularly:

1. Make sure you don't leave the contract in a exploitable state between the call and the callback.
2. Manually rollback any changes to the state in the callback if the external call failed.

We have a whole [security section](../security/callbacks) dedicated to these specific errors, so please go and check it.

<Warning>
  Not following these basic security guidelines could expose your contract to exploits. Please check the [security section](../security/callbacks), and if still in doubt, [join us in Discord](https://near.chat).
</Warning>
