Mastering Ethereum
上QQ阅读APP看书,第一时间看更新

Application layer

The application layer is the one where external programs interact with the blockchain. It also includes smart contract languages, such as Solidity and Vyper. This layer is the most important one, because it gives people the option to use the Ethereum blockchain for something more than just sending and storing cryptocurrencies, it's the next step regarding decentralized technology use cases. The following diagram shows the application layer:

First off, we have wallets that allow everyday users to manage private keys in order to be able to interact with decentralized applications (dApps) and make transfers.

The main ones are Mist, MetaMask and MyEtherWallet:

  • Mist is a work-in-progress browser that is always connected to Ethereum. It allows you to use dApps directly from it without having to worry about managing your account or using external plugins.
  • MetaMask is a plugin available on most browsers that give you the superpower to connect to the Ethereum blockchain without having to have a local copy of the blockchain, since it connects to a network of computers known as INFURA, where you can create transactions freely.
  • MyEtherWallet is a famous Ethereum wallet manager where you can store your funds, connect to your accounts, and interact with smart contracts online. You can also download an offline version for increased security and reliability.

Then, we have smart contract languages, such as Solidity and Vyper. They are the ones used to create smart contracts that interact with the blockchain with bytecode instructions. These work thanks to the miners that execute the code when blocks are mined. Solidity is the most used in ICOs, decentralized applications, and tokens, where users are able to interact with the blockchain in a trustless environment.

Next, we have libraries, such as Truffle, Embark and web3.js. They give you the tools to create better dApps while being able to interact with smart contracts:

  • Truffle: This library is well-known for being used in minimum viable products (MVPs), dApps, ICOs, and token contracts, since it provides a secure and tested environment for developers that want to go further.
  • Embark: This is a dApp framework made by the guys in Status that gives you utilities such as the capacity to automatically deploy contracts from the .js code, watch changes, and manage a variety of chains.
  • Web3.js: This is the most used library to interact with existing smart contracts on you web apps via JavaScript. It provides you with a simple interface that is intuitive and easy to learn.

Finally, you have testing tools to verify the security of your smart contracts. Keep in mind that these tools are not perfect, because they only provide you with extended options to test your code without forcing you to fully test all aspects of a decentralized application:

  • Sol-profiler: This is a simple profiler to generate a beautiful table that displays all your contracts and functions in an easy to understand manner. This is great for larger projects, where it starts to become hard to understand the relationship between all the components so that you're able to test them more efficiently.
  • Solidity coverage: This is a great testing tool written in JavaScript to ensure that your tests are actually checking every single line of code to at least guarantee that it is being fully tested without regards to quality testing. Truffle is a great tool to write tests, since it provides you with a testing framework that helps you execute unit tests.
  • Cliquebait: This provides you with a clean Docker image with the Ethereum blockchain using proof-of-authority with extremely fast block times so that you can deploy and check every feature of your decentralized applications without dependencies. 
  • Hevm: With hevm, you have a customized implementation of the Ethereum Virtual Machine (EVM) that shows you exactly what's going on in your smart contracts, including opcodes and a debugger where you can interact with the deployed smart contract directly.