clarinet icon indicating copy to clipboard operation
clarinet copied to clipboard

Empty contracts not actually published

Open obycode opened this issue 2 years ago • 0 comments

If my project includes an empty contract, or one that does not define any public functions, then clarinet doesn't actually treat it as a deployed contract. For example:

clarinet new empty
cd empty
clarinet contract new empty
clarinet contract new foo

Leave contracts/empty.clar as-is, and add the following to contracts/foo.clar:

(define-trait anything ())

(define-public (foo (c <anything>))
  (ok (print c))
)

Then run the console (clarinet console) and enter the following command:

(contract-call? .foo foo .empty)

Similarly, if you put that same contract call into another contract, you will see the error on clarinet check:

clarinet contract new bar

contracts/bar.clar:

(contract-call? .foo foo .empty)

clarinet check will give you:

error: use of unresolved contract 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.empty'
--> contracts/bar.clar:1:1
(contract-call? .foo foo .empty)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
x 1 error detected

obycode avatar Nov 02 '22 12:11 obycode