How can I structure my code in multiple files?

How can I put different parts of my contract in its own separate file (to keep sane)?

Programs tends to grow and being able to structure the code in different files feels like a basic language feature.

You can’t split your contract into multiple files, but you can split your code into multiple contacts that can be deployed under the same account.

Hi @pdahlberg! Don’t know if I correctly understand the question but I can say that under development I followed the kitty-items repository structure. You can check it here GitHub - onflow/kitty-items: Based on CryptoKitties, Kitty Items is an example of a full-stack dapp built on Flow.
If you look inside the kitty-items-cadence/cadence folder you can see how smart contracts are managed in different folders and file. I find it an intuitive organization.

You can also check the Decentology’s Dapp-Starter https://dappstarter.decentology.com Here you can create a repository that it’s already structured and configured, give it a try!

1 Like

Thanks for the link Fabius. I would have wished for a bit more freedom in separating things into separate files, but I can also see the reason for the current setup. I’m PoC:ing a game so I probably have a few more pieces than the kitty example I guess.