Configuration time Constants not working?

In my forc.toml:

[dependencies]
fuels = { version = "0.36", features = ["fuel-core-lib"] }
...

[[test]]
...

[constants]
token_b256 = { type = "b256", value = "0x0101010101010101010101010101010101010101010101010101010101010101" }
inception_period = { type = "u64", value = "42" }

Sway program:

contract
....
impl LockUp for Contract {
    #[payable, storage(read,write)]
    fn lock_up(user: Identity) {
        require(msg_asset_id() == ContractId::from(token_b256), Error::IncorrectToken);
        ...
    }
}

When I do forc build it says token_b256 does not exist in this scope

1 Like

Off the top of my head I’m not sure what the issue is. A workaround to fix your issue in the meantime would be to use constant at the top of your file like this: const TOKEN_B256 = "0x...". Also can you show me the output of forc --version?

> forc -V
forc 0.35.2

Constants in the toml file are being deprecated. They should no longer be used. Instead, either regular consts should be used or configurable { } blocks. configurable blocks are not documented yet but we’re doing that asap.

3 Likes