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

Olivieri, Luca
;
Spoto, Fausto;
2021-01-01

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.
2021
Third International Conference on Blockchain Computing and Applications (BCCA)
File in questo prodotto:
Non ci sono file associati a questo prodotto.

I documenti in ARCA 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: https://hdl.handle.net/10278/5047700
Citazioni
  • ???jsp.display-item.citation.pmc??? ND
  • Scopus 1
  • ???jsp.display-item.citation.isi??? 1
social impact