Programming the Blockchain

Programming the Blockchain

DOI: 10.4018/978-1-5225-2193-8.ch005
OnDemand PDF Download:
No Current Special Offers

Chapter Preview



Serpent is one of the high-level programming languages used to write smart contracts over Ethereum blockchain. This language is very similar to the Python programming language in its structure and ease of programming (Delmolino, 2015). It is basically intended to be a clean and simple programming language, incorporating most of the efficiency benefits of a low-level language with ease-of-use in programming style. This language has the potential to add exclusive domain-specific features into the contract code.

According to Ethereum Builder’s Guide (Ethereum Builder’s guide, 2016), the important differences between Serpent and Python are:

  • Python numbers have potentially unlimited size, Serpent numbers wrap around 2256. For example, in Serpent the expression 3^(2^254) surprisingly evaluates to 1, even though in reality the actual integer is too large to be recorded in its entirety within the universe.

  • Serpent has no decimals.

  • Serpent has no list comprehensions (expressions like [x**2 for x in my_list]), dictionaries or most other advanced features

  • Serpent has no concept of first-class functions. Contracts do have functions, and can call their own functions, but variables (except storage) do not persist across calls.

  • Serpent has a concept of persistent storage variables.

  • Serpent has an extern statement used to call functions from other contracts.

Complete Chapter List

Search this Book: