Skip to main content
QUICK REVIEW

[Paper Review] Flint for Safer Smart Contracts

Franklin Schrans, Daniel Hails|arXiv (Cornell University)|Apr 13, 2019
Blockchain Technology Applications and SecurityComputer Science16 references12 citations
TL;DR

Flint is a statically-typed, domain-specific programming language designed for writing secure, verifiable smart contracts on Ethereum. It enforces safety through protection blocks (access control via typestate), atomic asset operations, non-wrapping arithmetic, and default immutability—preventing common vulnerabilities like reentrancy, integer overflow, and accidental fund loss, with formal verification support and compiler-enforced correctness.

ABSTRACT

The Ethereum blockchain platform supports the execution of decentralised applications or smart contracts. These typically hold and transfer digital currency to other parties on the platform; however, they have been subject to numerous attacks due to the unintentional introduction of bugs. Over a billion dollars worth of currency has been stolen since its release in July 2015. As smart contracts cannot be updated after deployment, it is imperative that the programming language supports the development of robust contracts. We propose Flint, a new statically-typed programming language specifically designed for writing robust smart contracts. Flint's features enforce the writing of safe and predictable code. To encourage good practices, we introduce protection blocks. Protection blocks restrict who can run code and when (using typestate) it can be executed. To prevent vulnerabilities relating to the unintentional loss of currency, Flint Asset traits provide safe atomic operations, ensuring the state of contracts is always consistent. Writes to state are restricted, simplifying reasoning about smart contracts.

Motivation & Objective

  • To address the critical problem of smart contract vulnerabilities that have led to over $1 billion in losses since 2015.
  • To design a programming language that makes writing insecure smart contracts fundamentally unnatural or impossible.
  • To provide first-class language-level support for security patterns such as access control, atomic state updates, and safe arithmetic.
  • To shift the development model toward safety by construction, reducing reliance on post-deployment audits or runtime analysis.
  • To support formal verification and tooling integration, enabling developers to write correct, predictable, and maintainable contracts.

Proposed method

  • Introduces protection blocks that enforce who can call a function and in which contract state, using typestate to model valid execution sequences.
  • Defines a first-class Asset type for Ether (Wei), ensuring atomic transfer, split, and merge operations that prevent inconsistent balances.
  • Makes integer arithmetic non-wrapping by default, with explicit cyclic operators for cases requiring overflow behavior.
  • Enforces default immutability and private visibility for functions and variables, requiring explicit opt-in for mutability.
  • Restricts loops to finite for-in constructs, eliminating infinite loop vulnerabilities.
  • Uses static typing to catch type errors before deployment, ensuring correctness at compile time.

Experimental results

Research questions

  • RQ1Can a domain-specific programming language be designed to prevent common smart contract vulnerabilities such as reentrancy, integer overflow, and incorrect state transitions?
  • RQ2How can typestate and access control be integrated into a smart contract language to enforce correct execution order and caller authorization?
  • RQ3To what extent can atomic asset operations eliminate inconsistencies in contract balance accounting?
  • RQ4Can default immutability and safe arithmetic significantly reduce the attack attack vectors present in languages like Solidity?
  • RQ5How does the integration of formal safety guarantees into a practical language affect developer productivity and code correctness?

Key findings

  • Flint prevents reentrancy attacks by enforcing typestate-based access control, ensuring that sensitive operations are only callable in valid contract states.
  • The use of first-class Asset types ensures that all transfers are atomic and consistent, eliminating vulnerabilities related to incorrect balance tracking.
  • Integer arithmetic in Flint does not wrap; instead, it throws an exception on overflow, preventing silent data corruption.
  • The language’s default immutability and private visibility make it impossible to accidentally introduce mutable state without explicit declaration, reducing attack vectors.
  • The compiler enforces that all state changes are restricted and predictable, simplifying reasoning about contract behavior.
  • Performance benchmarks show Flint’s compiled code is comparable to Solidity, even without optimization passes, indicating practical viability.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.