Post
Share your knowledge.
Type checking error when using a custom struct as a type parameter in Sui Move's coin::Coin?
Question:
I'm encountering a type checking error in my Sui Move code that I don't understand. Here's a simplified version of my code:
module my_module::mymodule {
use sui::coin;
use sui::wallets;
struct MyCoin has drop {}
public fun create_coin(): coin::Coin<MyCoin> {
coin::mint(1000)
}
}
When I try to compile, I get the following error:
Invalid type parameter instantiation.
Expected type 'phantom type T' but found 'MyCoin'
What am I doing wrong? Why can't I use MyCoin
as a type parameter for coin::Coin
, and how can I fix this type checking issue?
- Sui
- Architecture
Answers
4You’re hitting this type checking error because coin::Coin
The coin module in Sui is designed to be generic, where the coin type is just a marker — like a label to distinguish one coin from another. That’s why it expects the type to carry no actual data and only exist for typing purposes.
You’re attempting to use coin::mint(1000) without properly registering your custom coin type MyCoin. In Sui Move, before you can mint a custom coin, you need to define and register it using the create_currency function.
You’re getting the error because sui::coin::Coin
module my_module::mymodule {
use sui::coin;
struct MyCoin has drop, store {} // add `store` because it's often required
phantom struct PhantomMyCoin has drop, store {}
public fun create_coin(): coin::Coin<PhantomMyCoin> {
coin::mint<PhantomMyCoin>(1000)
}
}
You’re trying to use your custom MyCoin as a type argument for coin::Coin
Invalid type parameter instantiation. Expected type 'phantom type T' but found 'MyCoin'
What this means in plain terms is: coin::Coin
So, unless your type is declared like this:
phantom struct MyCoin has store, drop {}
…it cannot be used with coin::Coin
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.

- ... SUIBigSneh+1396
- ... SUISuiLover+1333
- ... SUI0xduckmove+1207
- ... SUIThorfin+1202
- ... SUIOwen+970
- ... SUIharry phan+847
- ... SUItheking+742
- Why does BCS require exact field order for deserialization when Move structs have named fields?53
- Multiple Source Verification Errors" in Sui Move Module Publications - Automated Error Resolution43
- Sui Transaction Failing: Objects Reserved for Another Transaction25
- How do ability constraints interact with dynamic fields in heterogeneous collections?05