FuelLabs/fuels-rs · error · syn::Error

Consider adding: Contract(name="{}", project=...)

Error message

Consider adding: Contract(name="{}", project=...)

What it means

Compile-time validation error from setup_program_test: a DeployContract command references a contract binding name that is not produced by the Abigen command. validate_all_contracts_are_known takes the set difference of names being deployed vs contract bindings declared under ProgramType::Contract; each unknown name yields two errors — one on the name literal ('Contract is unknown') and this one on the Abigen span suggesting the fix.

Source

Thrown at packages/fuels-macros/src/setup_program_test/parsing/validations.rs:44

            Err(err)
        }
    }
}

pub(crate) fn validate_all_contracts_are_known(
    abigen_command: &AbigenCommand,
    deploy_commands: &[DeployContractCommand],
) -> Result<()> {
    extract_contracts_to_deploy(deploy_commands)
        .difference(&names_of_program_bindings(
            abigen_command,
            ProgramType::Contract,
        ))
        .flat_map(|unknown_contract| {
            [
                Error::new_spanned(unknown_contract, "Contract is unknown"),
                Error::new(
                    abigen_command.span,
                    format!(
                        "Consider adding: Contract(name=\"{}\", project=...)",
                        unknown_contract.value()
                    ),
                ),
            ]
        })
        .validate_no_errors()
}

pub(crate) fn validate_all_scripts_are_known(
    abigen_command: &AbigenCommand,
    load_commands: &[LoadScriptCommand],
) -> Result<()> {
    extract_scripts_to_load(load_commands)
        .difference(&names_of_program_bindings(
            abigen_command,

View on GitHub (pinned to d9a250a518)

Solutions

  1. Make the DeployContract name string exactly match a contract binding name in Abigen (case-sensitive).
  2. If the contract is genuinely missing, add it: Abigen(contracts = [(name = "my_contract", project = "...")]) as the message suggests.
  3. Verify the program is listed under contracts= and not scripts=/predicates= in the Abigen command.

Example fix

// before
setup_program_test!(
    Abigen(contracts = [(name = "counter", project = "../counter")]),
    DeployContract(name = "ctr", salt = "0x00"),
)
// after
setup_program_test!(
    Abigen(contracts = [(name = "counter", project = "../counter")]),
    DeployContract(name = "counter"),
)
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: DeployContract(name = "my_contract") where the Abigen command has no contract binding named "my_contract" (typo, casing mismatch, or the binding exists only under scripts/predicates rather than contracts), or the name was copy-pasted from another test.

Common situations: Renaming a binding in Abigen but not in DeployContract; deploying a binding that was declared as the wrong program type; stale copied test scaffolding.

Related errors


AI-assisted analysis of FuelLabs/fuels-rs@d9a250a518 (2026-08-16). Data as JSON: /api/errors/2c7553aaa6bb44f2. Report an issue: GitHub.