# Error.ts:35 FuelError: Invalid struct Vec. Field "buf" not present

**URL:** <https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941>\
**Category:** TypeScript SDK\
**Created:** [October 30, 2024, 12:47pm UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941 "2024-10-30T12:47:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeraB](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/gerab/32/3690_2.png) [@GeraB](https://forum.fuel.network/u/GeraB)\
**Post date:** [October 30, 2024, 12:47pm UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/1 "2024-10-30T12:47:17Z")

</div>

Hi people!  
When executing a function I get this error

```auto
error.ts:35 FuelError: Invalid struct Vec. Field "buf" not present.

```

According to ABI, these are the parameter types

```auto
    is_whitelisted: InvokeFunction<
      [
        user: IdentityInput,
        max_payment: BigNumberish,
        key: BigNumberish,
        proof: Vec<string>,
      ],
      boolean
    >;

```

And I’m passing this as a parameter to “proof”, which correspond to the type specified in the ABI:

```auto
['0x084a71ec624e85335823e25249c22fa9d7a483bd9e637f4a0baa4029fe4eaf06', '0xddedf04e87aad7b7fd3142c9210feee40e06e24b8a5213aec569b1e77c528c80', '0xfb74eff4869e9d1470546566afeb9e8f550d26376a04edb58cd329ec180333a8']

```

PS: executing the function in the console, directly to the contract, it executes correctly, so an error in the contract could be ruled out.

---

<div class="post-metadata">

**Author:** ![p.s](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/p.s/32/2491_2.png) [@p.s](https://forum.fuel.network/u/p.s)\
**Post date:** [October 30, 2024, 2:09pm UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/2 "2024-10-30T14:09:51Z")

</div>

> [@GeraB](#):
>
> When executing a function I get this error
> 
> ```auto
> 
> ```

Hi @GeraB 👋

Could you share the Sway code for the function `is_whitelisted`, the ABI (if possible) and the contract ID of the contract that you called directly?

---

<div class="post-metadata">

**Author:** ![GeraB](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/gerab/32/3690_2.png) [@GeraB](https://forum.fuel.network/u/GeraB)\
**Post date:** [October 30, 2024, 2:36pm UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/3 "2024-10-30T14:36:34Z")

</div>

Sure!

function:

```auto
    #[storage(read)]
    fn is_whitelisted(user: Identity, max_payment:u256,key:u64, proof:Vec<b256>) -> bool{
        check_whitelist(user,max_payment,key,proof)
    }

```

ABI:

```auto
    is_whitelisted: InvokeFunction<
      [
        user: IdentityInput,
        max_payment: BigNumberish,
        key: BigNumberish,
        proof: Vec<string>,
      ],
      boolean
    >;

```

ContractID

```auto
fuel1ey5d3q9zm28yl4gzy9gv04cd89ft4735llus669uylkw74ae6mgq57ncfr

```

---

<div class="post-metadata">

**Author:** ![p.s](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/p.s/32/2491_2.png) [@p.s](https://forum.fuel.network/u/p.s)\
**Post date:** [October 30, 2024, 3:16pm UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/4 "2024-10-30T15:16:27Z")

</div>

I tried to replicate your issue, but everything worked as expected.

Could you share a repository, either of your full project or a minimum reproduction of the issue?

---

<div class="post-metadata">

**Author:** ![GeraB](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/gerab/32/3690_2.png) [@GeraB](https://forum.fuel.network/u/GeraB)\
**Post date:** [October 30, 2024, 3:34pm UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/5 "2024-10-30T15:34:41Z")

</div>

I can’t share the repo, but this is the hook where I’m using that function.

```auto
export function useUserWhitelisted({
  contract,
  user,
  userMerkleProof,
  enabled,
}: Props) {
  const { data, isLoading, isFetched } = useQuery({
    queryKey: [
      "useUserWhitelisted",
      contract?.id?.toString(),
      user,
      userMerkleProof?.node,
    ],

    queryFn: async () => {
      try {
        if (!userMerkleProof) return false;

        const identityInput = toIdentityAddressInput(user?.bech32 as string);

        // This is showed correctly;
        console.log("__IDENTITY INPUT", identityInput);
        console.log("MERKLE PROOF VALUE ", userMerkleProof?.value);
        console.log("MERKLE PROOF KEY OF VALUE ", userMerkleProof?.keyOfProof);
        console.log("MERKLE PROOF ", userMerkleProof?.proof_nodes);

        const result = await contract?.functions
          .is_whitelisted(
            identityInput,
            userMerkleProof?.value || 0,
            userMerkleProof?.keyOfProof || 0,
            userMerkleProof?.proof_nodes || [],
          )
          .get();

        if (result) {
          console.log("RESULT", result);

          return result.value;
        }
        return false;
      } catch (e) {
        const parsedError = parseFuelError(e);
        const msg = customReportError(e);

        if (parsedError.log) {
          throw new Error(parsedError.log);
        } else if (parsedError.message) {
          throw new Error(parsedError.message);
        }

        throw new Error(msg);
      }
    },
    enabled:
      !!contract &&
      !!enabled &&
      userMerkleProof !== undefined &&
      (!!user || userMerkleProof === null),
  });

  return {
    data,
    isPending: isLoading,
    isFetched: isFetched,
  };
}

```

---

<div class="post-metadata">

**Author:** ![GeraB](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/gerab/32/3690_2.png) [@GeraB](https://forum.fuel.network/u/GeraB)\
**Post date:** [October 31, 2024, 12:43pm UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/6 "2024-10-31T12:43:01Z")

</div>

@p.s This is the complete error:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/d/d2ef4485838e9cbf601d4160c807b581e3c228ec.png)

---

<div class="post-metadata">

**Author:** ![p.s](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/p.s/32/2491_2.png) [@p.s](https://forum.fuel.network/u/p.s)\
**Post date:** [November 1, 2024, 8:38am UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/7 "2024-11-01T08:38:38Z")

</div>

It’s challenging to debug this issue without reproducing it.

What `fuels` version are you using?

---

<div class="post-metadata">

**Author:** ![GeraB](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/gerab/32/3690_2.png) [@GeraB](https://forum.fuel.network/u/GeraB)\
**Post date:** [November 1, 2024, 11:57am UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/8 "2024-11-01T11:57:44Z")

</div>

At that time I was using version 0.96.1, I stop appearing using version 0.91.0 but I lose the functions to connect to the dapp with Metamask or Solana.

---

<div class="post-metadata">

**Author:** ![p.s](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/p.s/32/2491_2.png) [@p.s](https://forum.fuel.network/u/p.s)\
**Post date:** [November 4, 2024, 4:56am UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/9 "2024-11-04T04:56:40Z")

</div>

What `forc` versions are you using?

---

<div class="post-metadata">

**Author:** ![GeraB](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/gerab/32/3690_2.png) [@GeraB](https://forum.fuel.network/u/GeraB)\
**Post date:** [November 4, 2024, 12:45pm UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/10 "2024-11-04T12:45:12Z")

</div>

I’m using 0.66.2 now

---

<div class="post-metadata">

**Author:** ![p.s](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/p.s/32/2491_2.png) [@p.s](https://forum.fuel.network/u/p.s)\
**Post date:** [November 4, 2024, 12:54pm UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/11 "2024-11-04T12:54:40Z")

</div>

Could you share the JSON ABI that is generated in the out directory of you contract (e.g. `contract_name/out/contrac-name-abi.json`)?

---

<div class="post-metadata">

**Author:** ![GeraB](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/gerab/32/3690_2.png) [@GeraB](https://forum.fuel.network/u/GeraB)\
**Post date:** [November 4, 2024, 1:11pm UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/12 "2024-11-04T13:11:33Z")

</div>

Sure! I put it on this folder:  
[https://drive.google.com/drive/folders/1-i6y-DzrR5lr7eYiMJZdnRWAHg1\_FShl?usp=sharing](https://drive.google.com/drive/folders/1-i6y-DzrR5lr7eYiMJZdnRWAHg1_FShl?usp=sharing)

---

<div class="post-metadata">

**Author:** ![GeraB](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/gerab/32/3690_2.png) [@GeraB](https://forum.fuel.network/u/GeraB)\
**Post date:** [November 4, 2024, 11:47pm UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/13 "2024-11-04T23:47:37Z")

</div>

Hey @p.s ! I have just created a simple repo with the bug, I hope it will help you

> **[GitHub - geraBarboni/Fuel-error](https://github.com/geraBarboni/Fuel-error)**
>
> Contribute to geraBarboni/Fuel-error development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![p.s](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/p.s/32/2491_2.png) [@p.s](https://forum.fuel.network/u/p.s)\
**Post date:** [November 5, 2024, 8:09am UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/14 "2024-11-05T08:09:06Z")

</div>

> [@GeraB](#):
>
> I’m using 0.66.2 now

That’s perfect, thanks @GeraB.

So in the [`useSalesContract` hook](https://github.com/geraBarboni/Fuel-error/blob/main/src/hooks/useGetContract/useSaleContract.ts#L3) you reference the [`SaleContractAbi__factory`](https://github.com/geraBarboni/Fuel-error/blob/main/src/services/contracts/sale/factories/SaleContractAbi__factory.ts#L8) which was built using forc `0.62.0`. We have also since changed our ABI specification in forc [`0.63.0`](https://docs.fuel.network/docs/migrations-and-disclosures/migrations/sway/#new-abi-specification-format---6254), which might be why you’re experiencing these issue.

I’d suggest the following:

- Ensure you’re using the latest `forc` version.  
(Run `fuelup upgrade` from your terminal)
- Deleting the generating TypeScript types folders ([`services/contract/sale`](https://github.com/geraBarboni/Fuel-error/tree/main/src/services/contracts/sale) and [`services/contract/staking`](https://github.com/geraBarboni/Fuel-error/tree/main/src/services/contracts/staking)).
- Re-run the type generation via `fuels build` or `fuels typegen`.
- Re-deploy the contracts to ensure versions are aligned correctly.

---

<div class="post-metadata">

**Author:** ![GeraB](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/gerab/32/3690_2.png) [@GeraB](https://forum.fuel.network/u/GeraB)\
**Post date:** [November 5, 2024, 2:18pm UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/15 "2024-11-05T14:18:34Z")

</div>

Thanks for that guide @p.s!, I implemented it to update everything but I keep getting the same error.  
The changes are uploaded in the repo

 ![image](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/6/65274e8a97d32044f4914bd8bc764e93a7939413.png)

---

<div class="post-metadata">

**Author:** ![GeraB](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/gerab/32/3690_2.png) [@GeraB](https://forum.fuel.network/u/GeraB)\
**Post date:** [November 5, 2024, 9:23pm UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/16 "2024-11-05T21:23:25Z")

</div>

Yes, it’s definitely not just that. What could be missing? Did you try with the js code as well or just from console directly to the contract? 🤔

---

<div class="post-metadata">

**Author:** ![p.s](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/p.s/32/2491_2.png) [@p.s](https://forum.fuel.network/u/p.s)\
**Post date:** [November 6, 2024, 4:49am UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/17 "2024-11-06T04:49:42Z")

</div>

Hey @GeraB 👋

It still appears that you’re building with an old version of `forc` resulting in the old specification of the ABI being built.

I’ve created the following [PR](https://github.com/geraBarboni/Fuel-error/pull/1) that showcases the rebuild contract in the correct format, and I can successfully run your dApp. I had to use a slimmed down version of the `SaleContract` with only the `is_whitelisted` method (as that’s the only function you provided.

If you’d like me to take a look at your project then feel free to add me to your private repository and I can help expedite your issue.

---

<div class="post-metadata">

**Author:** ![GeraB](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/gerab/32/3690_2.png) [@GeraB](https://forum.fuel.network/u/GeraB)\
**Post date:** [November 8, 2024, 11:54am UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/18 "2024-11-08T11:54:14Z")

</div>

Hey @p.s! Sorry for the delay, I’ve been working on it and it worked fine, thank you very much for your help. 🤗

---

<div class="post-metadata">

**Author:** ![p.s](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/p.s/32/2491_2.png) [@p.s](https://forum.fuel.network/u/p.s)\
**Post date:** [November 11, 2024, 4:32am UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/19 "2024-11-11T04:32:50Z")

</div>

> [@p.s](#):
>
> If you’d like me to take a look at your project then feel free to add me to your private repository and I can help expedite your issue.

You’re most welcome - please let us know if you face further issues.

---

<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:** [December 2, 2024, 12:33am UTC](https://forum.fuel.network/t/error-ts-35-fuelerror-invalid-struct-vec-field-buf-not-present/6941/20 "2024-12-02T00:33:44Z")

</div>

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