Flows Smart Contract Candence Fundamentals For New Developers

2 min read

Josh Hannan is sharing his deep knowledge of Cadence’s resource-oriented programming language with us as a senior smart contract engineer at Dapper Labs. His experience in the blockchain space began in early 2017, when he worked on Ethereum projects. The majority of his efforts have gone into writing Cadence smart contracts and documentation, as well as contributing to community efforts within the Flow ecosystem. Many of his projects, including the NBA Top Shot smart contract, are his work.

Josh is so passionate about smart contracts and Cadence that he started his very own blog, where he dives into a variety of Cadence related topics, making it one of the best resources in the community. It’s an awesome wealth of knowledge that we want to make sure everyone gets a chance to look at.

Cadence is a fascinating language, and we hope these posts from Josh leave you feeling the same way we do about it! We’ll update this post with additional sections as he publishes them, making this a great one-stop shop for your Cadence needs.  

‍

Taking your First Steps with Cadence

What is Flow, how do you get started with Cadence, and where should someone learning this resource-oriented programming language begin their journey? Josh shares an amazing array of helpful places everyone dipping their toes in for the first time should check out. 

Learn the ropes of Cadence

Basic Access Control in Cadence

Access control is the restriction of fields, functions, and types to certain scopes and users. It is an extremely important tool for developers to deeply consider to ensure their code is protected against potential vulnerabilities. Every developer should have a thorough understanding of Cadence access control before even thinking about deploying their project on mainnet, and Josh is here to make sure of that. 

Get up to speed with access control on Cadence

‍

A retrospective of the Cadence Cup

Haven’t heard of the Cadence Cup? It’s just one of the ways we engage with the Flow community and challenge developers to push the boundaries of Cadence. Josh takes a look back and highlights some of the interesting projects that were shared, which can be a great resource in learning about the possibilities of building on Flow.

Check out this awesome retrospective of the Cadence Cup

‍

What I’ve learned in the year since I wrote the NBA Top Shot smart contracts

Top Shot is a large project with many moving parts, but the record of Moment ownership and value transfer is handled by a few smart contracts on the Flow blockchain, which Josh was in charge of writing. He looks back at how it was created, what he’s learned since then, and what he would approach differently today. 

‍Get Josh’s thoughts on building the NBA Top shot smart contract

‍

Creating a token on the Flow blockchain? Don’t forget this VITAL part!

Josh dives deep into the one of the most critical parts of every token contract that you cannot forget. Make sure this one line is in every smart contract on mainnet. If not, you should either update it immediately or contact the developer to do so. 

Learn more about this critical detail

‍

How I organize my Cadence projects

It is very important to keep your code clear and organized, especially for smart contract code. This includes the way you name fields and functions, how you organize the definitions and structure within a contract or transaction, and how well the code is documented. Josh shares his thoughts on how to best organize the files for your project in your Github repository. 

Add some new tricks to your organizational toolbelt

Optionals in Cadence? Not Optional!

Optionals in Cadence are a safe, albeit somewhat complicated way to use variables. Optionals say either “there is a value, and it is x” or “there isn’t a value at all.” So the value either has been set or, more importantly, has not been set. They are an important feature of many languages and learning to use them properly is important for writing clean and secure code.

Learn about these important not-so-optionals

‍

Access Control and msg.sender In Cadence

One question that every Solidity user asks when they start programming in Cadence is “how do I check msg.sender?” On Ethereum, checking msg.sender is used to identify the account that is calling a function and to modify that function’s behavior appropriately. Cadence does not have msg.sender, but there’s a very specific reason for that!

Learn about why the design of Cadence is intentionally different

Original Post HERE