Skip to content

lesson-2 no longer compile #6

@richard5334

Description

@richard5334

Dear Encode,

    public entry fun collect_profits(_: &ShopOwnerCap, shop: &mut CarShop, ctx: &mut TxContext) {
        let amount = balance::value(&shop.balance);
        let profits = coin::take(&mut shop.balance, amount, ctx);

        transfer::transfer(profits, tx_context::sender(ctx))
    }

in car_shop.move cause the following error:

Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("0000000000000000000000000000000000000000000000000000000000000000::car_shop::collect_profits. Invalid call to '0000000000000000000000000000000000000000000000000000000000000002::transfer::transfer' on an object of type '0x2::coin::Coin<0x2::sui::SUI>'. The transferred object's type must be defined in the current module. If the object has the 'store' type ability, you can use the non-internal variant instead, i.e. 0000000000000000000000000000000000000000000000000000000000000002::transfer::public_transfer'"), command: None } }

Commenting the code allows it to compile. Im unsure as to what would be the fix as I'm still a beginner!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions