macro_rules! external_blueprint {
    (
        $blueprint_ident:ident {
            $($blueprint_contents:tt)*
        }
    ) => { ... };
}
Expand description

Generates a bridge/stub to make package calls to a blueprint.

If you just wish to instead make calls to an instantiated component, see the external_component macro.

Examples

use radix_engine_interface::address::Bech32Decoder;
use scrypto::prelude::*;

external_blueprint! {
    CustomAccountBlueprint {
        fn instantiate_global(account_name: &str) -> ComponentAddress;
    }
}

#[derive(Categorize, Encode, Decode, LegacyDescribe)]
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 instantiate_custom_account() -> ComponentAddress {
    let package_address = Bech32Decoder::for_simulator()
        .validate_and_decode_package_address("package_sim1qyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqsnznk7n")
        .unwrap();
    let blueprint = CustomAccountBlueprint::at(package_address, "CustomAccount");
    blueprint.instantiate_global("account_name")
}
  • Replaces the import! macro for importing an abi, using a more concise, readable syntax.
  • Similar to the external_component macro, which is used for making cross-component calls to an already-instantiated component.