From Ethereum To Flow – An Introduction To The Flow Blockchain
Ethereum is not in a state to support a massively successful blockchain game, see how Flow blockchain and Cadence smart contract language provide an optimized solution.
Join the DZone community and get the full member experience.Join For Free
In the fast-paced world of Web3, there is no shortage of innovative new technologies to explore. If you are a Solidity developer looking to build on a blockchain that is faster, safer, and more scalable than Ethereum, then Flow is an option you can’t ignore.
Flow was built from the ground up as an alternative to slower, less user-friendly layer 1 blockchains with its own custom-built smart contract language, one optimized for creating and managing digital assets.
This article will introduce the Flow blockchain in greater detail, unpack its smart contract language Cadence, and look at exactly why an Ethereum developer should consider building on Flow.
What Is Flow?
In 2017, a new Ethereum collectibles game, CryptoKitties, developed by the Canadian company Dapper Labs, made headlines after it caused the Ethereum network massive congestion while only having 10,000 users. The developers at Dapper Labs quickly realized that the Ethereum network was not optimized to operate and scale a successful game, so they started working on an alternative.
The end result of Dapper Lab’s efforts is the Flow Blockchain—a decentralized and developer-friendly blockchain designed to scale without sharding. Flow is highly optimized for the creation and management of digital assets such as NFTs.
The Four Main Pillars of Flow
The Flow blockchain has four key pillars at its foundation:
These four pillars set Flow apart and help solve common challenges typically faced by other blockchains. Let’s look at each of these items in detail.
Flow’s unique design uses a multi-role architecture that allows the network to scale. This is achieved with a validator node that is separated into four different roles: collection, consensus, execution, and verification. Simply put, the collection node batches, the consensus node secures, the execution node completes, and the verification node checks the work. Every node still participates in validating transactions, but they each specialize in different stages of the process, effectively increasing the transaction throughput.
Flow’s second pillar is resource-oriented programming. Cadence is a resource-oriented programming language that is used to develop smart contracts on the Flow blockchain. This optimized smart contract language uses a strong, static type system which helps minimize errors. It also allows pre- and post-conditions to be used, so developers can enforce expected behaviors. We’ll cover more on Cadence in the next section.
Developer ergonomics is the third pillar of Flow. From the beginning, the Flow creators focused on supporting developers and making their lives easier.
The Cadence smart contract language was built from the ground up to make creating and managing assets efficient and less prone to errors.
Upgradeable smart contracts help minimize bugs in code, creating a more secure ecosystem overall (more on contract immutability below).
Built-in logging support gives developers a means to trace a program’s behavior. This is a much sought-after feature that many blockchain ecosystems cannot provide.
Creating a consumer-friendly onboarding experience for new users is the fourth pillar of Flow. Human-readable security ensures users make informed decisions when running transactions. For example, instead of signing a transaction of hashes or confusing numbers and letters, Flow’s human-readable transactions ensure a level of transparency, clearly stating what permissions a user may be authorizing.
The account model for Flow also keeps users in mind. Flow wallets feature built-in, optional, and modular smart contract functionality which enable more complex authorization controls or automated processes. These features in turn create a better experience by making sure users cannot lose their assets while also providing options for account recovery in case of lost keys. Additionally, multi-signature support equips wallets with added security by allowing users to regularly cycle old keys.
What Is Cadence?
Along with the faster, more scalable blockchain, Flow’s developer team created a new smart contract language, Cadence. Digital assets are one of the most important aspects of blockchain development, and now there is finally a language that optimizes their creation and management.
Cadence’s syntax takes inspiration from other modern programming languages such as Swift, Kotlin, and Rust. It is the first high-level, resource-oriented programming language and utilizes a strong static type system. This effectively helps cut down on runtime errors and ensures expected behavior.
What does resource-oriented mean? In Cadence, special data types, called resources, are based on linear data types and represent digital ownership of assets on Flow. These resources, such as NFTs, are stored directly in a user’s account, rather than reflected as a record on a public digital ledger, and can only exist in one place at a time. This means the ownership of digital assets on Flow is defined directly in the language itself, effectively removing the risks involved with storing balances on a centralized digital ledger.
Additionally, Cadence improves asset management through the enforcement of strict rules that govern possible operations. Devs must define resource types with an ‘@’ symbol before explicitly moving, storing, or destroying them. This forced management of assets removes the possibility of losing or accidentally deleting an asset because of an error in the code and reduces human error.
Cadence, similar to Flow, is built on pillars—this time, five of them:
Safety and security - Cadence uses a strong static type system, built-in ownership primitives based on linear types, and a foundational focus on asset management to ensure expected behavior of code and minimize attack vectors for hackers.
Clarity - The declarative nature of Cadence ensures developers are explicit with their intentions, making the code easier to read, write, and audit.
Approachability - Cadence’s syntax and semantics are inspired by languages such as Swift and Rust, which make it familiar, while thorough documentation and efficient tooling create an approachable environment for developers to quickly get up to speed.
Developer experience - The Flow ecosystem provides resources to deliver support throughout the entire development lifecycle.
Intuiting ownership with resources - The concept of asset ownership is built into the Cadence language itself through the use of resources, rather than a central ledger. Assets are directly tied to an account’s storage and can be freely transferred without a smart contract.
Why Should Developers Build on Flow?
With all the protocol improvements introduced by Flow, they are clearly ushering in a new era of blockchain technology that focuses on developer acquisition and user experience. The suite of tools available enable a productive development lifecycle, while their extensive architecture guidelines ensure devs coming from Ethereum, or new to Web3 in general, have a thorough understanding of the types of solutions Flow is optimized for.
Tools such as the Flow Client Library (FCL) JS and Flowser make getting started easier than ever. The FCL JS package makes wallet integrations extremely easy, while its powerful SDK provides all the tools necessary to create dapps quickly and securely. Flowser (Flow Browser) is one of the most innovative new blockchain development tools, allowing you to not only inspect the states of Flow mainnet, testnets, or emulators, but also manage custom emulators and wallets through its GUI.
Additionally, the Flow blockchain prioritizes environmental impact just as much as other aspects of the protocol. And for this reason, it is arguably one of the most eco-friendly blockchains on the planet. Not only do they use less energy than every proof of work blockchain, but most proof of stake blockchains as well. This is thanks to its consensus mechanism and unique multi-role architecture mentioned earlier in this article. To put its energy use into perspective, for the energy cost of performing one Google search, you could create 12 Flow NFTs.
So let’s dive a little deeper into why developers should build on Flow by comparing it to Web3’s largest contributor, Ethereum.
Flow and Ethereum: A Closer Look
To get a better idea of how Flow compares to Ethereum, let’s take a closer look at a couple of important aspects and differences.
Transaction fees and speed
Ethereum is notorious for having extremely expensive transaction costs when network demand is high. The high fees are a mechanism used by the network to keep transaction volume at a manageable level. When blockspace demand is high, the fees go up to discourage people from deploying. Additionally, blocks on Ethereum are confirmed every 12 to 14 seconds, with finalization occurring within 6 blocks, or just over a minute. This leads to a maximum transactional throughput of ~15 transactions per second. In order to serve the needs of millions of users, significant improvements must be made.
Flow, on the other hand, was created with these challenges in mind. The multirole architecture mentioned above enables block finalization to occur roughly every 2.5 seconds, which leads to approximately 100 transactions per second. The fees to deploy and transact on mainnet are also just a fraction of what they would be on Ethereum’s mainnet.
Depending how you look at it, the immutability of Ethereum smart contracts once deployed can either be a good thing or a bad thing. On one hand, not being able to edit smart contracts after they’ve been deployed ensures a certain level of trust. It confirms that the code you are interacting with can’t be changed or repurposed once it’s live. On the flip side, code is rarely deployed in perfect shape, even with teams of incredibly skilled coders. Any small imperfection can lead to massive breaches, resulting in major losses. In order to fix a flawed smart contract, developers must deploy a whole new contract and ensure their user base uses that one instead.
Flow takes the above scenario into consideration with their approach to smart contract immutability. When contracts are deployed to the Flow blockchain, they are mutable by default. This means that developers can easily make changes should any complications arise with the live contract. Of course, this doesn’t imply smart contracts skip the testing phase altogether. Teams developing contracts will typically use software development best practices to test and iterate on contracts in testnet before final deployment to mainnet..
After some time has passed on mainnet, and the smart contract has met any final testing or security checks, developers have the option to revoke the keys to the account holding the smart contract. This process eliminates the ability to make any further changes, effectively making the smart contract immutable. The ability for smart contract developers to enforce immutability on any contract at any time is a clear advantage Flow has over Ethereum and other blockchain networks.
Beyond the technical advantages, Flow’s community is growing at a rapid pace. A strong developer ecosystem, accessible network participation, and content partners are all helping with awareness and leading to a steady increase of transactions on Flow. June 2022 was a record-breaking month for Flow, reaching close to 34 million transactions.
Most people think of NBA TopShot when they hear Flow blockchain; however, Flow has seen rapid expansion in the DeFi and gaming space. Leading the gaming space, Chainmonsters and Zeedz have the highest sales according to Flowverse, a Flow Blockchain aggregator. DeFi projects include decentralized exchanges BloctoSwap, built by Blocto, and IncrementFi. You can take a look at some of the other projects that have been built on Flow here.
The Flow ecosystem also received $725 million from the Flow Ecosystem Fund to help developers who are building on Flow. With the added incentive to build, the number of projects deciding to build on Flow will continue to bloom.
With the technical advantages, increasing popularity, and availability of funding on Flow, the need for Flow/Cadence developers has never been higher.
Following the success of CryptoKitties, the Dapper Labs team quickly realized that Ethereum was not in a state to support a massively successful blockchain game. Their struggles with Ethereum led to the creation of the Flow blockchain and Cadence smart contract language, both optimized for the creation and management of digital assets.
There has never been a better time for Ethereum and Solidity devs to start building on a faster, safer, and more scalable blockchain. If you’re interested in learning more about developing on Flow or how to use Cadence, you can visit the new developer portal. There, you’ll find more information on how to get started.
Have a really great day!
Opinions expressed by DZone contributors are their own.