# Any suggestions what values to be used here?

**URL:** <https://forum.fuel.network/t/any-suggestions-what-values-to-be-used-here/5268>\
**Category:** TypeScript SDK\
**Created:** [May 10, 2024, 11:48am UTC](https://forum.fuel.network/t/any-suggestions-what-values-to-be-used-here/5268 "2024-05-10T11:48:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![shivamlync](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/shivamlync/32/2807_2.png) [@shivamlync](https://forum.fuel.network/u/shivamlync)\
**Post date:** [May 10, 2024, 11:48am UTC](https://forum.fuel.network/t/any-suggestions-what-values-to-be-used-here/5268/1 "2024-05-10T11:48:03Z")

</div>

- In case of a nft deployed, while minting the nft what is the value of `sub_id: SubId` argument in the mint function.

[Mint Function](https://github.com/FuelLabs/sway-applications/blob/master/NFT/NFT-contract/src/main.sw#L261)

```ts
 #[storage(read, write)]
    fn mint(recipient: Identity, sub_id: SubId, amount: u64) {
        require_not_paused();

        // Checks to ensure this is a valid mint.
        let asset = AssetId::new(contract_id(), sub_id);
        require(amount == 1, MintError::CannotMintMoreThanOneNFTWithSubId);
        require(
            storage
                .total_supply
                .get(asset)
                .try_read()
                .is_none(),
            MintError::NFTAlreadyMinted,
        );
        require(
            storage
                .total_assets
                .try_read()
                .unwrap_or(0) + amount <= MAX_SUPPLY,
            MintError::MaxNFTsMinted,
        );

        // Mint the NFT
        let _ = _mint(
            storage
                .total_assets,
            storage
                .total_supply,
            recipient,
            sub_id,
            amount,
        );
    }

```

---

<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:** [May 10, 2024, 12:41pm UTC](https://forum.fuel.network/t/any-suggestions-what-values-to-be-used-here/5268/2 "2024-05-10T12:41:17Z")

</div>

Hey @shivamlync 👋

For the `sub_id` , we expect a `b256`. For the TS-SDK specifically, we expect the `b256` to be a string, so a little like below:

```ts
const value = await contract.functions.mint(
  identityInput,
  '0x0000000000000000000000000000000000000000000000000000000000000000', 
  100
)
.call();

```

---

<div class="post-metadata">

**Author:** ![shivamlync](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/shivamlync/32/2807_2.png) [@shivamlync](https://forum.fuel.network/u/shivamlync)\
**Post date:** [May 10, 2024, 12:43pm UTC](https://forum.fuel.network/t/any-suggestions-what-values-to-be-used-here/5268/3 "2024-05-10T12:43:25Z")

</div>

What is sub\_id? Can you explain. Also facing FuelError: The transaction reverted because a “require” statement has thrown an error.  
this error

---

<div class="post-metadata">

**Author:** ![shivamlync](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/shivamlync/32/2807_2.png) [@shivamlync](https://forum.fuel.network/u/shivamlync)\
**Post date:** [May 10, 2024, 12:45pm UTC](https://forum.fuel.network/t/any-suggestions-what-values-to-be-used-here/5268/4 "2024-05-10T12:45:03Z")

</div>

This worked for the first time, but it didn’t work the after that. I did use the same arguments as above

---

<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:** [May 10, 2024, 12:54pm UTC](https://forum.fuel.network/t/any-suggestions-what-values-to-be-used-here/5268/5 "2024-05-10T12:54:58Z")

</div>

In an NFT contract, `sub_id` is the unique identifier that differentiates tokens.

The `sub_id` can be anything such as `0x00..00` , `0x00..01` , `0x00..02` , etc if you wanted a standard 10,000 mint NFT collection. Each of these NFTs would have their own AssetId.

Do you have a repository link you don’t mind sharing?

---

<div class="post-metadata">

**Author:** ![shivamlync](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/shivamlync/32/2807_2.png) [@shivamlync](https://forum.fuel.network/u/shivamlync)\
**Post date:** [May 10, 2024, 12:56pm UTC](https://forum.fuel.network/t/any-suggestions-what-values-to-be-used-here/5268/6 "2024-05-10T12:56:03Z")

</div>

When I try to mint the second time, it throws this error

```ts
The transaction reverted because a "require" statement has throws an error.

```

How can I make it look like this

```auto
The sub_id can be anything such as 0x00..00 , 0x00..01 , 0x00..02 , etc if you wanted a standard 10,000 mint NFT collection. Each of these NFTs would have their own AssetId.

```

---

<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:** [May 10, 2024, 12:59pm UTC](https://forum.fuel.network/t/any-suggestions-what-values-to-be-used-here/5268/7 "2024-05-10T12:59:51Z")

</div>

You will need a unique `sub_id` for each new mint:

```ts
import { getRandomB256 } from "fuels"

const subId = getRandomB256();
const value = await contract.functions.mint(
  identityInput,
  subId, 
  100
)
.call();

```

---

<div class="post-metadata">

**Author:** ![shivamlync](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/shivamlync/32/2807_2.png) [@shivamlync](https://forum.fuel.network/u/shivamlync)\
**Post date:** [May 10, 2024, 1:00pm UTC](https://forum.fuel.network/t/any-suggestions-what-values-to-be-used-here/5268/8 "2024-05-10T13:00:55Z")

</div>

```rust
 let asset = AssetId::new(contract_id(), sub_id);
        require(amount == 1, MintError::CannotMintMoreThanOneNFTWithSubId);
        require(
            storage
                .total_supply
                .get(asset)
                .try_read()
                .is_none(),
            MintError::NFTAlreadyMinted,
        );
        require(
            storage
                .total_assets
                .try_read()
                .unwrap_or(0) + amount <= 100_000,
            MintError::MaxNFTsMinted,
        );

```

Accoding to this total assets are 100k, so if I use same subId say `0x00000000000000` for all the accounts that mint it, then would it work or would throw the above error?

@p.s

---

<div class="post-metadata">

**Author:** ![shivamlync](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/shivamlync/32/2807_2.png) [@shivamlync](https://forum.fuel.network/u/shivamlync)\
**Post date:** [May 10, 2024, 1:03pm UTC](https://forum.fuel.network/t/any-suggestions-what-values-to-be-used-here/5268/9 "2024-05-10T13:03:33Z")

</div>

Also can provide a documentation where subId is explain in detail.  
@p.s

---

<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:** [May 10, 2024, 1:36pm UTC](https://forum.fuel.network/t/any-suggestions-what-values-to-be-used-here/5268/10 "2024-05-10T13:36:48Z")

</div>

You may find the [nightly docs](https://docs.fuel.network/docs/nightly/sway/blockchain-development/native_assets/#the-subid-type) more helpful.

If you could share a link to your repository, I _may_ be able to assist further 🙂

* * *

Just found the following post you might find useful!

> [@Ownership of native assets](https://forum.fuel.network/t/ownership-of-native-assets/3106/5):
>
> It’s up to the developer! If the contract only creates a single token, we expect the SubId will often be 0 For NFTs, the SubIds might be sequential In the case of “vault” type tokens, the subId might be the AssetId of the underlying asset ENS-style naming applications might use a namehash-type algorithm You can even use asset sub-ids to represent contract state! Pass some state into the asset subId, and you can then reconstruct the assetId in a separate contract or predicate to prove state (I…
