# Using vectors on predicate configurable

**URL:** <https://forum.fuel.network/t/using-vectors-on-predicate-configurable/5339>\
**Category:** Sway\
**Created:** [May 22, 2024, 11:45pm UTC](https://forum.fuel.network/t/using-vectors-on-predicate-configurable/5339 "2024-05-22T23:45:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![guimroque](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/guimroque/32/1462_2.png) [@guimroque](https://forum.fuel.network/u/guimroque)\
**Post date:** [May 22, 2024, 11:45pm UTC](https://forum.fuel.network/t/using-vectors-on-predicate-configurable/5339/1 "2024-05-22T23:45:30Z")

</div>

I currently have a predicate with some configurable ones, and one of them is an array of type [b256;10].

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

This is a problem if I want to have this array with non-zero lengths.

How could I use a vector in these configurables?

Remembering that configurables cannot receive values that have not yet been instantiated, such as ([ref](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/vec.sw)):

`SIGNERS: Vec<b256> = Vec::new()`

---

<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 23, 2024, 7:08am UTC](https://forum.fuel.network/t/using-vectors-on-predicate-configurable/5339/2 "2024-05-23T07:08:14Z")

</div>

You can instantiate an empty vec with [Sway by Example](https://www.swaybyexample.com/vector)  
`SIGNERS_VEC: StorageVec<u64> = StorageVec {}`

```auto
predicate;

use std::{storage::storage_vec::*};

configurable {
    REQUIRED_SIGNATURES: u64 = 0,
    SIGNERS: [Address; 3] = [
        Address::from(0x0000000000000000000000000000000000000000000000000000000000000000),
        Address::from(0x0000000000000000000000000000000000000000000000000000000000000000),
        Address::from(0x0000000000000000000000000000000000000000000000000000000000000000)
    ],
    SIGNERS_VEC: StorageVec<u64> = StorageVec {},
}

fn main() -> bool {
    false
} 

```

---

<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 23, 2024, 8:32am UTC](https://forum.fuel.network/t/using-vectors-on-predicate-configurable/5339/3 "2024-05-23T08:32:52Z")

</div>

Hmmm, `StorageVec` is meant to be used only in the storage. Having it as a configurable just puts an empty struct in the configurable and that struct cannot be changed any more.  
In general, configurables must have a size known at the compile time. That’s why we cannot store dynamic structures there.  
What is your exact use case? Do you know the upper bound of the signers? E.g. knowing there will be no more then 10. Then you can have a configurable tuple where the first element would be the actual count e.g. SIGNERS: (u8, [b256;10]) = [all zeros]. In the SDK you can then set the SIGNERS.0 to e.g. 3 and fill the first three elements of the array and left others to be zero.

---

<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 23, 2024, 11:46am UTC](https://forum.fuel.network/t/using-vectors-on-predicate-configurable/5339/4 "2024-05-23T11:46:48Z")

</div>

Just heard back from the sway team and according to them, at the moment, we do not support “dynamic types” on configurable. It is something we are aiming for in the “near future”. Especially because it seems necessary in some cases. But using two configurable: (len, array) is the best workaround we have at the moment.

---

<div class="post-metadata">

**Author:** ![guimroque](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/guimroque/32/1462_2.png) [@guimroque](https://forum.fuel.network/u/guimroque)\
**Post date:** [May 23, 2024, 12:01pm UTC](https://forum.fuel.network/t/using-vectors-on-predicate-configurable/5339/5 "2024-05-23T12:01:14Z")

</div>

Great suggestion, seems to work well for me  
thanks 🙂

---

<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 13, 2024, 8:01am UTC](https://forum.fuel.network/t/using-vectors-on-predicate-configurable/5339/6 "2024-06-13T08:01:16Z")

</div>

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