Skip to main content

call_contract

Function call_contract 

Source
pub fn call_contract(
    contract_id: &AccountId,
    calldata: &[u8],
) -> Result<Vec<u8>>
Expand description

Invokes another contract without transferring value.

This is the legacy cross-contract call mechanism. The called contract executes with the same caller context (the original transaction sender).

§Arguments

  • contract_id - The 32-byte address of the contract to call
  • calldata - Encoded function selector and arguments

§Returns

  • Ok(Vec<u8>) - The return data from the called contract
  • Err(Error) - If the call fails or the contract doesn’t exist

§Gas

The called contract shares the remaining gas budget of the current execution.

§Example

use truthlinked_sdk::call;

let token_contract = [0x12; 32];
let calldata = encode_balance_of(account);
let balance_bytes = call::call_contract(&token_contract, &calldata)?;
let balance = decode_u128(&balance_bytes);