Component Ownership

Scrypto allows a component to own other components, similar to how a component can own vaults. If a component is owned by another component, its methods may only be accessed by the blueprint of the parent component.

An example of component ownership:

use scrypto::prelude::*;

mod child {
    struct Child {
        name: String,

    impl Child {
        fn new_component(name: String) -> ChildComponent {
            Self {

        pub fn get_name(&self) -> String {

mod parent {
    struct Parent {
        child0: ChildComponent,
        child1: ChildComponent,

    impl Parent {
        fn new_component() -> ParentComponent {
            let child0: ChildComponent = Child::new("child0".to_string());
            let child1: ChildComponent = Child::new("child1".to_string());

            // Move the two child components into a new parent component
            let parent_component = Self {

            // child0 and child1 are now owned by this parent_component

        pub fn new_globalized() -> Global<Parent> {

        pub fn get_child0_name(&self) -> String {

        pub fn get_child1_name(&self) -> String {

Note in the above example how the name of the struct gets an automatic suffix of Component when instantiated. We are still iterating on finding the best way to handle this, and this may change in the future.