# Forc build giving compilation error

**URL:** <https://forum.fuel.network/t/forc-build-giving-compilation-error/2954>\
**Category:** Sway\
**Created:** [July 30, 2023, 10:11am UTC](https://forum.fuel.network/t/forc-build-giving-compilation-error/2954 "2023-07-30T10:11:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ragib70](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/ragib70/32/1139_2.png) [@ragib70](https://forum.fuel.network/u/ragib70)\
**Post date:** [July 30, 2023, 10:11am UTC](https://forum.fuel.network/t/forc-build-giving-compilation-error/2954/1 "2023-07-30T10:11:37Z")

</div>

**Default host:** aarch64-apple-darwin

**fuelup home:** /Users/mdragibhussain/.fuelup

**installed toolchains**

* * *

beta-2-aarch64-apple-darwin

beta-3-aarch64-apple-darwin (default)

latest-aarch64-apple-darwin

latest-2023-01-18-aarch64-apple-darwin

**active toolchain**

* * *

beta-3-aarch64-apple-darwin (default)

**forc** : 0.37.3

**- forc-client**

**- forc-deploy** : 0.37.3

**- forc-run** : 0.37.3

**- forc-doc** : 0.37.3

**- forc-explore** : 0.28.1

**- forc-fmt** : 0.37.3

**- forc-index** : 0.18.4

**- forc-lsp** : 0.37.3

**- forc-tx** : 0.37.3

**- forc-wallet** : 0.2.2

**fuel-core** : 0.17.11

**fuel-indexer** : 0.18.4

**fuels versions**

* * *

**forc** : 0.39

data\_structures.sw

library data\_structures;

pub enum State {  
Initialized: (),  
Uninitialized: (),  
}

impl core::ops::Eq for State {  
fn eq(self, other: Self) → bool {  
match (self, other) {  
(State::Initialized, State::Initialized) =\> true,  
(State::Uninitialized, State::Uninitialized) =\> true,  
\_ =\> false,  
}  
}  
}

pub struct TokenMetadata {  
// This is left as an example. Support for dynamic length string is needed here  
name: str[7],  
}

impl TokenMetadata {  
pub fn new() → Self {  
Self {  
name: “Example”,  
}  
}  
}

errors.sw

library errors;

pub enum InitError {  
CannotReinitialize: (),  
NotInitialized: (),  
}

// TODO: can rename back to AccessError once [Name collision on types of different contracts · Issue #791 · FuelLabs/fuels-rs · GitHub](https://github.com/FuelLabs/fuels-rs/issues/791) is fixed  
pub enum ValidityError {  
MaxTokensMinted: (),  
NoContractAdmin: (),  
SenderNotAdmin: (),  
}

interface.sw

library interface;

dep data\_structures;

use data\_structures::TokenMetadata;

abi Auxiliary {  
/// Sets the inital state and unlocks the functionality for the rest of the contract.  
///  
/// This function can only be called once.  
///  
/// # Arguments  
///  
/// \* `new_admin` - The administrator to be set for this contract.  
/// \* `new_max_supply` - The maximum supply of tokens that may ever be minted.  
///  
/// # Reverts  
///  
/// \* When the contract has already been initalized  
#[storage(read, write)]  
fn constructor(new\_admin: Option, new\_max\_supply: Option);

```
/// Returns the metadata for a specific token.
///
/// # Arguments
///
/// * `token_id` - The id of the token which the metadata should be returned.
#[storage(read)]
fn token_metadata(token_id: u64) -> Option<TokenMetadata>;

```

}

main.sw

contract;

dep data\_structures;  
dep errors;  
dep interface;

use data\_structures::{State, TokenMetadata};  
use errors::{InitError, ValidityError};  
use interface::Auxiliary;  
use std::auth::msg\_sender;  
use nft::{  
administrator::{  
admin,  
Administrator,  
set\_admin,  
},  
approve,  
approved,  
balance\_of,  
burnable::{  
burn,  
Burn,  
},  
is\_approved\_for\_all,  
mint,  
NFT,  
owner\_of,  
set\_approval\_for\_all,  
supply::{  
max\_supply,  
set\_max\_supply,  
Supply,  
},  
token\_metadata::{  
set\_token\_metadata,  
token\_metadata,  
},  
tokens\_minted,  
transfer,  
};

storage {  
state: State = State::Uninitialized,  
}

impl Administrator for Contract {  
#[storage(read)]  
fn admin() → Option {  
admin()  
}

```
#[storage(read, write)]
fn set_admin(new_admin: Option<Identity>) {
    require(admin().is_some(), ValidityError::NoContractAdmin);
    set_admin(new_admin);
}

```

}

impl Burn for Contract {  
#[storage(read, write)]  
fn burn(token\_id: u64) {  
set\_token\_metadata(Option::None::(), token\_id);  
burn(token\_id);  
}  
}

impl Auxiliary for Contract {  
#[storage(read, write)]  
fn constructor(new\_admin: Option, new\_max\_supply: Option) {  
require(storage.state == State::Uninitialized, InitError::CannotReinitialize);  
storage.state = State::Initialized;

```
    set_admin(new_admin);
    set_max_supply(new_max_supply);
}

#[storage(read)]
fn token_metadata(token_id: u64) -> Option<TokenMetadata> {
    token_metadata(token_id)
}

```

}

impl NFT for Contract {  
#[storage(read, write)]  
fn approve(approved\_identity: Option, token\_id: u64) {  
approve(approved\_identity, token\_id);  
}

```
#[storage(read)]
fn approved(token_id: u64) -> Option<Identity> {
    approved(token_id)
}

#[storage(read)]
fn balance_of(owner: Identity) -> u64 {
    balance_of(owner)
}

#[storage(read)]
fn is_approved_for_all(operator: Identity, owner: Identity) -> bool {
    is_approved_for_all(operator, owner)
}

#[storage(read, write)]
fn mint(amount: u64, to: Identity) {
    require(storage.state == State::Initialized, InitError::NotInitialized);
    require(admin().is_none() || (msg_sender().unwrap() == admin().unwrap()), ValidityError::SenderNotAdmin);
    require(max_supply().is_none() || (tokens_minted() + amount <= max_supply().unwrap()), ValidityError::MaxTokensMinted);

    mint(amount, to);

    let mut token_index = tokens_minted() - amount;
    while token_index < tokens_minted() {
        set_token_metadata(Option::Some(TokenMetadata::new()), token_index);
        token_index += 1;
    }
}

#[storage(read)]
fn owner_of(token_id: u64) -> Option<Identity> {
    owner_of(token_id)
}

#[storage(write)]
fn set_approval_for_all(approval: bool, operator: Identity) {
    set_approval_for_all(approval, operator);
}

#[storage(read)]
fn tokens_minted() -> u64 {
    tokens_minted()
}

#[storage(read, write)]
fn transfer(to: Identity, token_id: u64) {
    transfer(to, token_id);
}

```

}

impl Supply for Contract {  
#[storage(read)]  
fn max\_supply() → Option {  
max\_supply()  
}

```
#[storage(read, write)]
fn set_max_supply(supply: Option<u64>) {
    require(storage.state == State::Uninitialized, InitError::CannotReinitialize);
    set_max_supply(supply)
}

```

}

All 4 files are present in the src directory and the main.sw file is importing these dependencies but on compilation (forc build) I’m getting the following error:

**Compiling** contract **nft-contract0** (/Users/mdragibhussain/Documents/BlockchainProjects/fuel-project/fresh-start/nft-contract/nft-contract0)

**error**

**→** /Users/mdragibhussain/Documents/BlockchainProjects/fuel-project/fresh-start/nft-contract/nft-contract0/src/main.sw:3:1

**|**

**1 |**

**2 |**

**3 |** dep data\_structures;

**|**  **^^^**  **Expected an item.**

**4 |** dep errors;

**5 |** dep interface;

**|**

* * *

Aborting due to 1 error.

Error: Failed to compile nft-contract0

---

<div class="post-metadata">

**Author:** ![calldelegation](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/calldelegation/32/1484_2.png) [@calldelegation](https://forum.fuel.network/u/calldelegation)\
**Post date:** [July 31, 2023, 1:33am UTC](https://forum.fuel.network/t/forc-build-giving-compilation-error/2954/2 "2023-07-31T01:33:06Z")

</div>

Hey @ragib70 keyword `dep` has been deprecated for `mod` [here](https://github.com/FuelLabs/sway/releases/tag/v0.36.0/) since v0.36.0. You have a lot following errors after. I wasn’t able to get through them all because of the formatting. If you follow up do you mind repasting the code files properly?

So instead of  
`dep data_structures;`  
you would use  
`mod data_structures;`

I am running the beta-3 toolchain

```auto
active toolchain
-----------------
beta-3-aarch64-apple-darwin (default)
  forc : 0.37.3
    - forc-client
      - forc-deploy : 0.37.3
      - forc-run : 0.37.3
    - forc-doc : 0.37.3
    - forc-explore : 0.28.1
    - forc-fmt : 0.37.3
    - forc-index : 0.15.0
    - forc-lsp : 0.37.3
    - forc-tx : 0.37.3
    - forc-wallet : 0.2.2
  fuel-core : 0.17.11
  fuel-indexer : 0.15.0

fuels versions
---------------
forc : 0.39

```

---

<div class="post-metadata">

**Author:** ![ragib70](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/ragib70/32/1139_2.png) [@ragib70](https://forum.fuel.network/u/ragib70)\
**Post date:** [July 31, 2023, 6:03am UTC](https://forum.fuel.network/t/forc-build-giving-compilation-error/2954/3 "2023-07-31T06:03:58Z")

</div>

Yes, I get it. I will be correcting them, and then will be following up.
