How I organize my Cadence projects

The value of organization and standardization

The Structure

contracts/
transactions/
lib/
idTableStaking/
admin/
delegation/
node/
scripts/
lib/
js/
python/
cplusplus/
go/
rust/
java/
...
...
  • contracts : Contains a package to get the contract code for every contract in the repo, replacing the import addresses with addresses that the caller specifies depending on the network being deployed to.
  • templates : Contains a package to get the code for every transaction and script template in the repo, replacing the import addresses with addresses that the caller specifies depending on the network being deployed to.
  • test : Contains emulator automated tests for the smart contracts and transactions. This makes use of the packages in the contracts and templates directories for the test, as well as language specific utility methods to make unit testing easier.

Application Code

  • Option 1: Use a different repo for the application: Since an application isn’t directly tied to a smart contract, an argument can be made that it should be in a different repo, and then import the packages from the main contract repo. This encourages the decentralized mindset, allows projects to protect proprietary application code, and de-clutters the main contract repo so that the focus can be on the most important part, the contracts.
  • Option 2: Use the same repo, but put the application in one or more top level directories. This would make testing and running the application easier, but could complicate the organization of the repository.

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Joshua Hannan

Joshua Hannan

Smart Contract Engineer at Dapper Labs, working with Cadence, the best language for smart contracts!