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
- Create a project
- Declare a contract interface like the following
access(all) contract interface A {
access(all) fun foo()
}
- Attempt to deploy the project with the
add-contract command
flow accounts add-contract ./cadence/contracts/A.cdc
- 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
Problem
Not able to deploy a contract interface using Flow CLI commands with the following error:
Steps to Reproduce
add-contractcommandThe error also occurs when adding the contract to
flow.jsonwith and without an alias and usingflow deployHowever, 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.
For reference, the hex-encoded format of the contract interface
A.cdcdefined above is61636365737328616c6c2920636f6e747261637420696e746572666163652041207b0a2020202061636365737328616c6c292066756e20666f6f28290a7d. 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