# Trait "AbiDecode" is not implemented for type "CustomStruct

**URL:** <https://forum.fuel.network/t/trait-abidecode-is-not-implemented-for-type-customstruct/5355>\
**Category:** Sway\
**Tags:** testnet, feedback\
**Created:** [May 25, 2024, 10:40am UTC](https://forum.fuel.network/t/trait-abidecode-is-not-implemented-for-type-customstruct/5355 "2024-05-25T10:40:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![theAusicist](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/theausicist/32/1987_2.png) [@theAusicist](https://forum.fuel.network/u/theAusicist)\
**Post date:** [May 25, 2024, 10:40am UTC](https://forum.fuel.network/t/trait-abidecode-is-not-implemented-for-type-customstruct/5355/1 "2024-05-25T10:40:34Z")

</div>

I’ve read in the docs somewhere that with the new v1 encoding, there’s an option of implementing custom encoding for structs. If none is available, the default is used. I’m getting the error: Trait “AbiDecode” is not implemented for type “CustomStruct”. where CustomStruct is a two-field struct. Unsure why the compiler is failing to decode this passed around functions, but how can I implement AbiDecode for this struct?

The struct itself is very simple:

```rust
struct CustomStruct {
    pub value: u256,
    pub is_neg: bool,
}

```

with some trait implementations for `From`, `core::ops::Eq`, `core::ops::Ord` and some struct public methods that operate on the field data in the structs

---

<div class="post-metadata">

**Author:** ![naz3eh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/naz3eh/32/2025_2.png) [@naz3eh](https://forum.fuel.network/u/naz3eh)\
**Post date:** [May 28, 2024, 4:04am UTC](https://forum.fuel.network/t/trait-abidecode-is-not-implemented-for-type-customstruct/5355/2 "2024-05-28T04:04:37Z")

</div>

Hey @theAusicist, can you please try [this](https://forum.fuel.network/t/how-do-you-make-a-custom-struct-serializable/5183/2) solution and see if it works?

---

<div class="post-metadata">

**Author:** ![theAusicist](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/theausicist/32/1987_2.png) [@theAusicist](https://forum.fuel.network/u/theAusicist)\
**Post date:** [May 28, 2024, 7:32am UTC](https://forum.fuel.network/t/trait-abidecode-is-not-implemented-for-type-customstruct/5355/3 "2024-05-28T07:32:59Z")

</div>

Hi @naz3eh unfortunately, the solution above is for the Rust SDK. The error in question I’ve raised above pertains to the Sway compiler being unable to compile the code itself with the following error:

```bash
Trait “AbiDecode” is not implemented for type “CustomStruct”

```

The struct itself has some trait implementations for `From`, `core::ops::Eq`, `core::ops::Ord` and some struct public methods that operate on the field data in the structs.

The error happens during a cross-contract call.

```rust
// Contract A
fn some_call() -> (u64, CustomStruct, u64, bool) {
...
}

// Contract B
fn call_contract_a() {
    let (one, _, three, four) = contr_a.some_call(); // doesn't error out 
    
    // errors out at compile time because we "actually" want the value of "CustomStruct"
    let (one, two, three, four) = contr_a.some_call(); 
}

```

I can confirm this wasn’t an issue at v0.49.3, the previous forc version I’d use. Upgrading to v0.60.0 changed that.

---

<div class="post-metadata">

**Author:** ![naz3eh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/naz3eh/32/2025_2.png) [@naz3eh](https://forum.fuel.network/u/naz3eh)\
**Post date:** [May 30, 2024, 5:32am UTC](https://forum.fuel.network/t/trait-abidecode-is-not-implemented-for-type-customstruct/5355/4 "2024-05-30T05:32:32Z")

</div>

Okay, let me check with the team and get back to you

---

<div class="post-metadata">

**Author:** ![naz3eh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/naz3eh/32/2025_2.png) [@naz3eh](https://forum.fuel.network/u/naz3eh)\
**Post date:** [May 30, 2024, 10:36am UTC](https://forum.fuel.network/t/trait-abidecode-is-not-implemented-for-type-customstruct/5355/5 "2024-05-30T10:36:07Z")

</div>

We are considering it as a bug for now and the team is working on it. You can follow up on the progress [here](https://github.com/FuelLabs/sway/issues/5936).

---

<div class="post-metadata">

**Author:** ![theAusicist](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/theausicist/32/1987_2.png) [@theAusicist](https://forum.fuel.network/u/theAusicist)\
**Post date:** [May 31, 2024, 7:07am UTC](https://forum.fuel.network/t/trait-abidecode-is-not-implemented-for-type-customstruct/5355/6 "2024-05-31T07:07:04Z")

</div>

this works.

Manually importing “CustomStruct” seems to do the trick.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/5/57d5a345cc15a64b636e0d56e042857f8a0e80b1.png) [@system](https://forum.fuel.network/u/system)\
**Post date:** [June 21, 2024, 3:07am UTC](https://forum.fuel.network/t/trait-abidecode-is-not-implemented-for-type-customstruct/5355/7 "2024-06-21T03:07:08Z")

</div>

Closed on June 21, 2024, 3:07am UTC

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
