Blockchain replicates the execution of transactions in a decentralized network of machines, supporting trust since each machine, by itself, cannot violate the rules for the transactions. Many applications of blockchains are related to the exchange of tokens, ie. valuable units that can be native, such as bitcoin and ether, or implemented in software, through smart contracts. Standards ensure token interoperability among decentralized applications of a certain platform, but they are general enough to be used in other contexts as well. A trend in blockchain is to implement such standards from a platform to another one, easing the design challenges with trusted and widely-used specifications. Exploiting the target language semantic can result in technological advantages with more efficient contracts. This paper presents a re-engineering of OpenZeppelin’s implementation of the ERC-20 standard for fungible tokens on Takamaka, a subset of Java for programming smart contracts in the Hotmoka blockchain. It starts with a literal translation from Solidity to Takamaka, but then describes a novel implementation for making snapshots of tokens, based on tree maps, that is possible in Java, but not in Solidity, and shows that it is much more efficient than the literal translation in Java from Solidity, within the Java Virtual Machine.

Re-engineering ERC-20 Smart Contracts with Efficient Snapshots for the Java Virtual Machine

Marco Crosara;Luca Olivieri;Fausto Spoto;Fabio Tagliaferro
2021

Abstract

Blockchain replicates the execution of transactions in a decentralized network of machines, supporting trust since each machine, by itself, cannot violate the rules for the transactions. Many applications of blockchains are related to the exchange of tokens, ie. valuable units that can be native, such as bitcoin and ether, or implemented in software, through smart contracts. Standards ensure token interoperability among decentralized applications of a certain platform, but they are general enough to be used in other contexts as well. A trend in blockchain is to implement such standards from a platform to another one, easing the design challenges with trusted and widely-used specifications. Exploiting the target language semantic can result in technological advantages with more efficient contracts. This paper presents a re-engineering of OpenZeppelin’s implementation of the ERC-20 standard for fungible tokens on Takamaka, a subset of Java for programming smart contracts in the Hotmoka blockchain. It starts with a literal translation from Solidity to Takamaka, but then describes a novel implementation for making snapshots of tokens, based on tree maps, that is possible in Java, but not in Solidity, and shows that it is much more efficient than the literal translation in Java from Solidity, within the Java Virtual Machine.
978-1-6654-2182-9
smart contract, software reengineering, blockchain, token, ERC-20
File in questo prodotto:
File Dimensione Formato  
Re-engineering ERC-20 Smart Contracts.pdf

solo utenti autorizzati

Descrizione: Articolo principale
Tipologia: Documento in Post-print
Licenza: Creative commons
Dimensione 327.99 kB
Formato Adobe PDF
327.99 kB Adobe PDF   Visualizza/Apri   Richiedi una copia

I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: http://hdl.handle.net/11562/1054784
Citazioni
  • ???jsp.display-item.citation.pmc??? ND
  • Scopus ND
  • ???jsp.display-item.citation.isi??? ND
social impact