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

# Cross-Contract

> Interact with a Soroban contract from within another Soroban contract.

A cross-contract invocation is a powerful (yet expensive) kind of contract interaction. A contract invocation is similar to starting a new process because the code that runs will be in a separate address space, meaning that they do not share any data other than what was passed in the invocation. While a contract invocation typically transfers control to a *different* contract, it is possible to transfer control to the currently running contract. Regardless of whether the contract that receives control is a different contract or the currently running contract, the value returned by `get_invoking_contract` will be the previous value of `get_current_contract`. A contract invocation can only access the public methods of a contract.

One public function is an exception: a contract's `__constructor` is invoked by the host at deployment, rather than by another contract. For example, the [token example contract] sets its admin and metadata in a constructor:

```rust theme={"theme":{"light":"github-light","dark":"github-dark"}}
#[contractimpl]
impl Token {
    pub fn __constructor(e: Env, admin: Address, decimal: u32, name: String, symbol: String) {
```

So instead of being invoked like other functions, its arguments are passed to `deploy_contract`, which deploys the contract and runs its constructor in the same invocation:

```rust theme={"theme":{"light":"github-light","dark":"github-dark"}}
e.deployer()
    .with_current_contract(salt)
    .deploy_contract(ContractExecutable::Wasm(token_wasm_hash), (admin, decimal, name, symbol))
```

In tests, the same arguments are passed to `register`:

```rust theme={"theme":{"light":"github-light","dark":"github-dark"}}
e.register(Token {}, (admin, decimal, name, symbol))
```

For calling a contract's other functions, see [Making cross-contract calls].

[token example contract]: https://developers.stellar.org/docs/build/smart-contracts/example-contracts/tokens.md

[making cross-contract calls]: https://developers.stellar.org/docs/build/guides/conventions/cross-contract.md
