Skip to main content

Differences vs EVM

This document summarizes the differences you might encounter between building on Flow vs. other blockchains, especially Ethereum. This will be most useful to developers who are already familiar with building on a blockchain system. Check out Why Flow for a more beginner-friendly overview of the Flow blockchain.

The Flow Account Model

Key pairs establish ownership on blockchains. In other blockchains (e.g. Bitcoin), the user’s address is also calculated based on their public key, making a unique one-to-one relationship between accounts (addresses) and public keys. This also means there is no concrete “account creation” process other than generating a valid key pair. With the advent of smart contracts, Ethereum introduced a new account type for deploying contracts that can use storage space (i.e., to store contract bytecode). You can learn more about the distinction between EOA and Contract accounts on Ethereum here.

Flow combines the concepts of EOAs and Contract Accounts into a single account model and decouples accounts and public keys. Flow accounts are associated with one or more public keys of varying weights that specify interested parties that need to produce valid cryptographic signatures for each transaction authorized by that account.

Screenshot 2023-08-16 at 16.43.07.png

This natively enables interesting use cases, like key revocation, rotation, and multi-signature transactions. All Flow accounts can use network storage (e.g., for deploying contracts and storing resources like NFTs) based on the number of FLOW tokens they hold.

info

You must run an explicit account creation transaction on Flow to create a new account. Flow CLI can create an account on any network with a given public key.

Check out the Accounts concept document to learn more about Flow accounts.

Smart Contracts

On Flow, smart contracts are written in Cadence. Cadence syntax is user-friendly and inspired by modern languages like Swift. Notable features of Cadence that make it unique and the key power of the Flow blockchain are:

  • Resource-oriented: Cadence introduces a new type called Resources. Resources enable onchain representation of digital assets natively and securely. Resources can only exist in one location at a time and are strictly controlled by the execution environment to avoid common mishandling mistakes. Each resource has a unique uuid associated with it on the blockchain. Examples of usage are fungible tokens, NFTs, or any custom data structure representing a real-world asset. Check out Resources to learn more.
  • Capability-based: Cadence offers a Capability-based Security model. This also enables the use of Resources as structures to build access control. Capabilities and Entitlements can provide fine-grained access to the underlying objects for better security. For example, when users list an NFT on a Flow marketplace, they create a new Capability to the stored NFT in their account so the buyer can withdraw the asset when they provide the tokens. Check out Capability-based Access Control to learn more about Capabilities on Cadence.
info

Cadence is not compiled. All contracts are open source on Flow.

Check out the Cadence website to learn more about Cadence.

If you are a Solidity developer, it's recommended to read Cadence's Guide for Solidity Developers to dive deeper into the differences between the two languages. Here are some additional resources that can help you get started with Cadence:

Transactions and Scripts

You can interact with the state on most other blockchains by cryptographically authorizing smart contract function calls. On Flow, transactions are more complex and are pieces of Cadence code. This means that any number of contracts and function calls can be composed together atomically to mutate the blockchain state.

Here is a sample transaction that mints an NFT from ExampleNFT contract on Testnet:


_47
import NonFungibleToken from 0x631e88ae7f1d7c20
_47
import ExampleNFT from 0x2bd9d8989a3352a1
_47
_47
/// Mints a new ExampleNFT into recipient's account
_47
_47
transaction(recipient: Address) {
_47
_47
/// Reference to the receiver's collection
_47
let recipientCollectionRef: &{NonFungibleToken.Collection}
_47
_47
/// Previous NFT ID before the transaction executes
_47
let mintingIDBefore: UInt64
_47
_47
prepare(signer: &Account) {
_47
_47
self.mintingIDBefore = ExampleNFT.totalSupply
_47
_47
// Borrow the recipient's public NFT collection reference
_47
self.recipientCollectionRef = getAccount(recipient)
_47
.capabilities.get<&{NonFungibleToken.Collection}>(ExampleNFT.CollectionPublicPath)
_47
.borrow()
_47
?? panic("The recipient does not have a NonFungibleToken Receiver at "
_47
.concat(ExampleNFT.CollectionPublicPath.toString())
_47
.concat(" that is capable of receiving an NFT.")
_47
.concat("The recipient must initialize their account with this collection and receiver first!"))
_47
_47
}
_47
_47
execute {
_47
_47
let currentIDString = self.mintingIDBefore.toString()
_47
_47
// Mint the NFT and deposit it to the recipient's collection
_47
ExampleNFT.mintNFT(
_47
recipient: self.recipientCollectionRef,
_47
name: "Example NFT #".concat(currentIDString),
_47
description: "Example description for #".concat(currentIDString),
_47
thumbnail: "https://robohash.org/".concat(currentIDString),
_47
royalties: []
_47
)
_47
}
_47
_47
post {
_47
self.recipientCollectionRef.getIDs().contains(self.mintingIDBefore): "The next NFT ID should have been minted and delivered"
_47
ExampleNFT.totalSupply == self.mintingIDBefore + 1: "The total supply should have been increased by 1"
_47
}
_47
}

Authorizing transactions is also more complex on Flow involving multiple roles:

  • Accounts can have multiple keys with varying weights
  • Multiple accounts can sign a single transaction (prepare takes any number of arguments)
  • Transaction computation fees can be paid by a different account, called the Payer account.
  • The transaction nonce is provided by the Proposer account. This enables rate control and order to be dictated by a different party if needed.
  • All of the above roles can be the same account.

The same powerful concept also exists for querying the blockchain state using Scripts. Here is a sample script that fetches the ExampleNFT IDs owned by a given account on Testnet:


_21
/// Script to get NFT IDs in an account's collection
_21
_21
import NonFungibleToken from 0x631e88ae7f1d7c20
_21
import ExampleNFT from 0x2bd9d8989a3352a1
_21
_21
access(all) fun main(address: Address, collectionPublicPath: PublicPath): [UInt64] {
_21
_21
let account = getAccount(address)
_21
_21
let collectionRef = account
_21
.capabilities.get<&{NonFungibleToken.Collection}>(collectionPublicPath)
_21
.borrow()
_21
?? panic("The account with address "
_21
.concat(address.toString())
_21
.concat("does not have a NonFungibleToken Collection at "
_21
.concat(ExampleNFT.CollectionPublicPath.toString())
_21
.concat(". The account must initialize their account with this collection first!")))
_21
_21
return collectionRef.getIDs()
_21
_21
}

Check out Transactions and Scripts to learn more about the concepts. You can also read the Cadence language reference on Transactions to dive deeper.

Flow Nodes

Developers need a blockchain node to send transactions and fetch state. Flow is based on a multi-node architecture that separates roles like consensus and computation. You can learn more about the Flow architecture here.

Access Nodes are the node type that are most useful for developers, as they provide access to the Flow network via an API.

SDKs and Tools

If you’re already familiar with blockchain development, here's a comparison between popular software packages and Flow's tooling: