onflow-cadence

How to import contracts in Cadence using flow.json instead of relative paths


Importing contracts using their relative path is not working atm with the last version of the cadence language server. I was wondering what would be the alternative, when developing locally, for importing other contracts. My best guess is that it should be using the flow.json file, defining the paths for the contracts on it, but I cannot find how to specify on my contract that I want to it to use the config file for the imports


Solution

  • LSP and flow-cli both read the flow.json file and parse depedencies the same way.

    In flow.json you specify the path to a file:

    In other contracst and interaction you then use the same path to import

    Hope that helps.