Skip to main content

Cross-Contract Calls

Contracts may call each other using the runtime library and indicating the

  • Contract Id: the callee's contract address;
  • Method Name: the name of the method which is to be called;
  • Method Args: the JSON-serialized arguments for the above method; fields of the JSON need to be in snake case.

Cross-contract calls are made through function Runtime::call_contract()

fn call_contract(contract_id: String, method_name: String, method_args: Option<String>) -> anyhow::Result<R>

Security Restrictions

Some restrictions on making cross-contract calls are in place:

  • The active cross-contract call frame should not exceed 5 This is to erroneous or malicious behavior that could exhaust all the resources and fuel.
  • Reentrancy is not enabled allowed by default . This means that there cannot exist a cycle in cross-contract calling sequence and is enforced to avoid the well-known Reentrancy Attack.