Solana Anchor: “IdlError: Type not found”

3 min readNov 29, 2022


Anchor IdlError, type not found
Photo by Erik Mclean on Unsplash

gm gm, I’m 0xksure and I write mostly about rust development and solana (usually with the anchor framework) development. I have a lot of experience in backend development, but have also done my fair share of frontend work and general sdk work using typescript. If you are interested in these topics then please check some of my previous writings

Transfer tokens between accounts on Solana

Transfer tokens between accounts on Solana

Mint tokens on Solana using the Rust SDK

Also, check out my daily takes on twitter


The error tells you that it isn’t possible to deserialize or serialize one of your types, typically in a struct. Typically the error would look like this

IdlError: Type not found: {“name”:”side”,”type”:{“defined”:”Side”}}

For which the type Side in this case does not implement any deserialization or serialization in the project.

How to fix it

Identify your type and make sure that it can can be serialized. Most primitive types like u64,i64,str, bool etc has this ability. However, when dealing with structs it is necessary to bring in a macro. If the compiler complains about

What’s weird is that your code compiles to the correct target so you would imagine there being no problem. But this error doesn’t stem from the rust compiler but rather from the IDL creation by anchor itself.

A case study

The error I encountered was

IdlError: Type not found: {“name”:”side”,”type”:{“defined”:”Side”}}

I knew I had seen it before and it took some discord scrolling and googling until I realized what I missed. I found this Side type here

As you can see on line 20 the struct OrderParams implements AnchorSerialize and AnchorDeserialize so that shouldn’t be an issue. All other types except side is primitive types so they should be easily serialized. The Side variable on the other hand is different.

The Side variable is

So it actually implements borsh deserialization- and serialization. But still it throws an error. The reason is simply because it’s imported from an external crate. It’s a bit of a gotcha.

The solution is to move out the struct to your project. This means ctrl+c ad ctrl+v unfortunately.

Hence, I ended up with this not too pretty solution

Useful links


If you ever encounter an IdlError for a type it is most certainly because the referenced type does not implement deserialization or serialization.