Skip to content

Cannot deploy contract interfaces via flow add-contract or flow deploy #1947

@sisyphusSmiling

Description

@sisyphusSmiling

Problem

Not able to deploy a contract interface using Flow CLI commands with the following error:

❌ Command Error: failed to find contract declaration

Steps to Reproduce

  1. Create a project
  2. Declare a contract interface like the following
access(all) contract interface A {
    access(all) fun foo()
}
  1. Attempt to deploy the project with the add-contract command
flow accounts add-contract ./cadence/contracts/A.cdc
  1. You'll get the reported error

The error also occurs when adding the contract to flow.json with and without an alias and using flow deploy

However, manually deploying the hex-encoded Cadence using a simple deployment transaction like the following does work. So it appears this is an issue with how Flow CLI detects contract declaration prior to deploying.

transaction(name: String, code: String) {
    prepare(signer: auth(AddContract) &Account) {
        signer.contracts.add(name: name, code: code.decodeHex())
    }
}

For reference, the hex-encoded format of the contract interface A.cdc defined above is 61636365737328616c6c2920636f6e747261637420696e746572666163652041207b0a2020202061636365737328616c6c292066756e20666f6f28290a7d. You can start emulator locally and run the transaction with the code and see the contract does successfully deploy when done so manually.

Acceptance Criteria

Contract interfaces can be deployed and updated across all networks using Flow CLI commands.

Context

Preparing for VM bridge contract deployments and upgrades

Metadata

Metadata

Assignees

Labels

BugThe issue represents a bug, malfunction, regression

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions