macro_rules! external_component {
    (
        $component_ident:ident {
            $($component_methods:tt)*
        }
    ) => { ... };
}
Expand description

Generates a bridge/stub to make cross-component calls.

Examples

use scrypto::prelude::*;
use sbor::{TypeId, Encode, Decode, Describe};

#[derive(TypeId, Encode, Decode, Describe)]
enum DepositResult {
    Success,
    Failure
}

external_component! {
    AccountInterface {
        fn deposit(&mut self, b: Bucket) -> DepositResult;
        fn deposit_no_return(&mut self, b: Bucket);
        fn read_balance(&self) -> Decimal;
    }
}

fn bridge_to_existing_account(component_address: ComponentAddress) {
    let existing_account = AccountInterface::from(component_address);
    let balance = existing_account.read_balance();
    // ...
}
  • Similar to the external_blueprint macro, but the external_component can be used without knowing the package and blueprint addresses.