Sui.

Post

Share your knowledge.

Meaning.Sui.
Jul 25, 2025
Expert Q&A

An error when deploying contract

I catch an error when deploying contract Error executing ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("Invalid entry point parameter type. Expected primitive or object type. Got: 0x2::balance::Balance<0x2::sui::SUI>"), command: None } } how can I fix that?

  • Sui
  • Architecture
1
4
Share
Comments
.

Answers

4
harry phan.
Jul 27 2025, 12:16

You're getting the error:

ExecutionError: Invalid entry point parameter type. Expected primitive or object type. Got: 0x2::balance::Balance<0x2::sui::SUI> because your entry fun is accepting a parameter of type Balance, which is not allowed as a direct argument in an entry function. In Sui Move, entry functions must only accept primitive types (e.g., u64, bool, address) or object types with has key, like &mut MyObject or ID. The type Balance is a generic struct, not a valid top-level entry argument.

✅ How to Fix It You need to pass the underlying object (usually a Coin) into the function, and then manipulate it internally to access the balance.

Instead of:

public entry fun my_function(balance: Balance, ctx: &mut TxContext) Do this:

public entry fun my_function(coin: Coin, ctx: &mut TxContext) Then inside the function, you can call:

let amount = coin::value(&coin); Or if you want to sum or split, use the coin module functions like merge, split, or zero.

🔗 Why This Happens The Sui VM does not allow arbitrary generic or complex struct types as entry function arguments because it needs to verify object ownership and serialization up front. Only:

u8, u64, bool, address &mut T where T: has key ID, Coin, and other has key object types ...can be used at the entry point.

📘 Docs to Review https://docs.sui.io/build/move/functions#entry-functions coin module reference: https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/packages/sui-framework/sources/coin.move

8
Comments
.
Owen.
Owen4662
Jul 30 2025, 17:10

The error occurs because you're using Balance<SUI> as a parameter in an entry function, which is not allowed. Entry functions in Sui Move can only accept primitive types (like u64, bool, vector<u8>) or object types (structs with key or store abilities), not generic wrappers like Balance.

To fix it, remove Balance<SUI> from the entry function parameters. If you need to interact with a balance, access it from within the function using the owner's address and the appropriate Sui framework APIs, or pass the owner's address and retrieve the balance object inside the function. Only valid object references or primitives should be used as entry function arguments.

7
Comments
.
Paul.
Paul4340
Jul 31 2025, 22:53

The error you're encountering is related to an invalid entry point parameter type when deploying your Sui Move contract. Specifically, it indicates that the contract expects a primitive or object type but received an invalid type (0x2::balance::Balance<0x2::sui::SUI>).

Possible Causes and Solutions:

  1. Incorrect Type in Function Definition:

    • Ensure that the entry function in your contract accepts the correct type. In Sui Move, types like Balance are not primitive types but more specialized types.
    • Double-check the type definition for the entry function, especially the type of parameters passed to it.

    Fix: If you are trying to pass a Balance type, you should either:

    • Use a u64 for the value (e.g., amount of tokens).
    • Properly wrap the balance in a struct or convert it to a primitive type.
  2. Type Mismatch Between Function Argument and Call:

    • The mismatch between the function signature and the type of argument passed could be the cause.
    • For example, if the function is expecting a u64 (primitive) but you’re passing a Balance, this mismatch would trigger an error.

    Fix: Make sure the function signature matches what’s being passed in the deployment call. For instance, if you're passing a Balance, ensure that you are passing the correct type that matches the Balance type in the contract.

  3. Fixing the Entry Point: Here's an example of what you might need to change:

    public entry fun transfer(amount: u64, recipient: address): bool {
        let sender_balance = borrow_global_mut<Balance>(@sender);
        if (*sender_balance >= amount) {
            *sender_balance -= amount;
            let recipient_balance = borrow_global_mut<Balance>(recipient);
            *recipient_balance += amount;
            return true;
        }
        return false;
    }
    

    Make sure that you're using u64 for the amount parameter in the entry function, not a Balance.

  4. Test with Proper Type Casting: If you're trying to pass a Balance object, check if it can be cast to a primitive type such as u64 during deployment.

Steps:

  • Review Contract Types: Ensure the types you're using are valid for the entry function parameters.
  • Check Entry Function Signatures: Ensure the expected types are aligned with the deployment parameters you're passing.
  • Deploy with Valid Arguments: When deploying, pass valid arguments (like a simple u64 or an object type if required, as per your contract logic).

If you still have trouble, feel free to share the function signature and how you're calling it. I can help refine the code further!

7
Comments
.
shamueely.
Jul 26 2025, 18:23

You're getting the error:

ExecutionError: Invalid entry point parameter type. Expected primitive or object type. Got: 0x2::balance::Balance<0x2::sui::SUI>

because your entry fun is accepting a parameter of type Balance<SUI>, which is not allowed as a direct argument in an entry function. In Sui Move, entry functions must only accept primitive types (e.g., u64, bool, address) or object types with has key, like &mut MyObject or ID. The type Balance<T> is a generic struct, not a valid top-level entry argument.


✅ How to Fix It

You need to pass the underlying object (usually a Coin<SUI>) into the function, and then manipulate it internally to access the balance.

Instead of:

public entry fun my_function(balance: Balance<SUI>, ctx: &mut TxContext)

Do this:

public entry fun my_function(coin: Coin<SUI>, ctx: &mut TxContext)

Then inside the function, you can call:

let amount = coin::value(&coin);

Or if you want to sum or split, use the coin module functions like merge, split, or zero.


🔗 Why This Happens

The Sui VM does not allow arbitrary generic or complex struct types as entry function arguments because it needs to verify object ownership and serialization up front. Only:

  • u8, u64, bool, address
  • &mut T where T: has key
  • ID, Coin<T>, and other has key object types

...can be used at the entry point.


📘 Docs to Review

2
Comments
.

Do you know the answer?

Please log in and share it.