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

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

You can also use this to make calls to the component itself. If you just wish to make calls to an instantiated component, see the external_component! macro.

Examples

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

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

external_blueprint! {
    {
        package: "package_sim1qyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqsnznk7n",
        blueprint: "CustomAccount"
    },
    CustomAccount {
        fn instantiate_global(account_name: &str) -> ComponentAddress;
        fn deposit(&mut self, b: Bucket) -> DepositResult;
        fn deposit_no_return(&mut self, b: Bucket);
        fn read_balance(&self) -> Decimal;
    }
}

fn create_custom_accounts() {
    let new_account_address = CustomAccount::instantiate_global("account_name");
    let mut account = CustomAccount::from(new_account_address);

    let empty_bucket = Bucket::new(ResourceAddress::from_str("resource_sim1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzqu57yag").unwrap());
    account.deposit(empty_bucket);
}

fn bridge_to_existing_account(component_address: ComponentAddress) {
    let existing_account = CustomAccount::from(component_address);
    let balance = existing_account.read_balance();
    // ...
}
  • 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.