ABSTRACT

Smart contracts can be considered as a way to automate some of the conditions and obligations described in the contract. In this chapter, we cover the smart contract programming with a special emphasis on Solidity, properties associated with a smart contract account, fetching accounts from Ganache module, deployment of smart contracts with Web3 and Infura, testing smart contracts with open-source tools such as Remix and Mocha framework for asynchronous testing, test coverage reports, and use of any assertion library. Hence, this chapter highlights methods for writing smart contracts using various authoring tools. There are multiple smart contract authoring tools including Visual Studio. However, the easiest and fastest way for developing and testing the smart contracts is to use a browser-based tool known as Remix. Next, we start writing few smart contract applications with Solidity language and explaining all the common function types used in it. The concepts of gas and transactions are thoroughly discussed. Lastly, this chapter is laid out in a manner that it helps the reader to get the comprehensive idea of writing smart contracts.