Post
Share your knowledge.
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
Answers
4You'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
✅ How to Fix It
You need to pass the underlying object (usually a Coin
Instead of:
public entry fun my_function(balance: Balance
public entry fun my_function(coin: Coin
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
📘 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
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.
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:
-
Incorrect Type in Function Definition:
- Ensure that the entry function in your contract accepts the correct type. In Sui Move, types like
Balanceare 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
Balancetype, you should either:- Use a
u64for the value (e.g., amount of tokens). - Properly wrap the balance in a struct or convert it to a primitive type.
- Ensure that the entry function in your contract accepts the correct type. In Sui Move, types like
-
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 aBalance, 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 theBalancetype in the contract. -
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
u64for theamountparameter in the entry function, not aBalance. -
Test with Proper Type Casting: If you're trying to pass a
Balanceobject, check if it can be cast to a primitive type such asu64during 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
u64or 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!
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 TwhereT: has keyID,Coin<T>, and otherhas keyobject types
...can be used at the entry point.
📘 Docs to Review
Do you know the answer?
Please log in and share it.
Sui is a Layer 1 protocol blockchain designed as the first internet-scale programmable blockchain platform.
- How to Maximize Profit Holding SUI: Sui Staking vs Liquid Staking616
- Why does BCS require exact field order for deserialization when Move structs have named fields?65
- Multiple Source Verification Errors" in Sui Move Module Publications - Automated Error Resolution55
- Sui Move Error - Unable to process transaction No valid gas coins found for the transaction419
- Sui Transaction Failing: Objects Reserved for Another Transaction410