Bøger / faglitteratur

Mastering Blockchain Programming with Solidity : Write Production-Ready Smart Contracts for Ethereum Blockchain with Solidity


Beskrivelse


Summary: With this book, you will learn to write production-ready smart contracts for the Ethereum blockchain. Finally, with the help of comprehensive examples, you will learn how to add security to smart contracts and then delve into the various security considerations that must be paid attention to.

Indhold

Seneste udgave,

Cover -- Title Page -- Copyright and Credits -- Dedication -- About Packt -- Foreword -- Contributors -- Table of Contents -- Preface -- Section 1: Getting Started with Blockchain, Ethereum, and Solidity -- Chapter 1: Introduction to Blockchain -- Understanding blockchain -- Blockchain solves the double-spending problem -- Properties of blockchain -- Distributed ledger -- Fault tolerance -- Attack resistance -- Remove intermediaries -- Consensus protocol -- Faster settlement -- Lower transaction fees -- Transparency -- Immutability -- Irreversible transactions -- Trust in the network -- Artificial trust -- Trustless systems -- Availability -- Empower individuals -- Chronological order of transactions -- Timestamped -- Sealed with cryptography -- When to use blockchain -- When not to use blockchain -- Blockchain is slow -- Blockchain depends on off-chain oracles -- Existing implementations of blockchain -- Cross-border payments -- Decentralized cloud storage -- Decentralized computing -- Introduction to Ethereum -- Ethereum is for writing decentralized applications -- Ethereum architecture -- P2P networks -- Nodes -- Full nodes -- Lightweight nodes -- Miners -- Blocks -- Ethereum Virtual Machine (EVM) -- Ether currency -- Smallest unit - wei -- Gas -- Gas limit -- Gas price -- Formulas -- Example -- Ethereum accounts -- Externally owned accounts -- Contract accounts -- The difference between an EOA and a contract -- Ethereum transaction -- Transaction fields -- From -- To -- Value -- Gas limit -- Gas price -- Nonce -- Data -- Transaction hash -- Transaction status -- Pending status -- Success status -- Fail status -- Dropped status -- Transaction operations -- Replace/update -- Cancel -- Testnets -- Smart contracts -- Immutable code -- Irreversible transactions -- Think twice before deploying -- Limited storage ; Every transaction consumes gas in ether -- Playing with ether or tokens -- Summary -- Questions -- Chapter 2: Getting Started with Solidity -- Introduction to the Solidity language -- The layout of a Solidity source file -- Solidity version with pragma -- Importing other source files -- Structure of a contract -- Declaring state variables -- Writing function definitions -- Creating a custom modifier using function modifiers -- Using events for logging and callback -- Custom data types with struct -- Custom types for constants with enum -- Solidity data types -- Understanding Solidity value types -- Integer value type -- Boolean value type -- Address value type -- Reading a contract's ether balance -- Sending ether using transfer -- Sending ether using send -- Understanding call and delegatecall functions -- Understanding the staticcall function -- Adjust gas for a transaction using gas -- Forwarding ether to another contract -- Changes in Solidity version 0.5.0 -- Fixed size byte arrays -- Dynamically sized byte arrays -- Understanding the bytes data type -- Understanding the string type -- Passing functions using function types -- Get a function type with function selector -- Using internal function types -- Using external function types -- Solidity reference types -- Understanding variables' data locations in Solidity -- Using arrays in Solidity -- Creating a key value map using mapping -- Resetting variables using the delete keyword -- Assigning variables with units -- Specifying ether amounts using ether units -- Supported units for time -- Global special variables and functions -- Using block and transaction properties -- Getting block information using the block variable -- Getting sender transaction info using the msg variable -- Getting the current time using the now variable -- Getting transaction info using the tx variable ; Special functions -- Application Binary Interface encoding functions -- Error handling in Solidity -- Cryptographic functions -- Contract-related functions -- Get the contract address using this keyword -- Destroying contracts using the selfdestruct function -- Destroying contracts using the suicide function -- Topics for self-study -- Summary -- Questions -- Further reading -- Chapter 3: Control Structures and Contracts -- Understanding Solidity control structures -- Returning multiple values from function -- Expression evaluation order -- Solidity contracts -- Creating contracts -- Creating child contracts using the new keyword -- Using variable and function visibility -- Getter functions for state variables -- Creating custom function modifiers -- Creating constant state variables -- Understanding types of Solidity functions -- Using view functions to read state variables -- Using pure functions to perform calculations -- Using the default fallback function -- Overloading functions -- Overriding function definition -- Using emit and events for event logging -- Inheriting contracts -- Passing arguments for the base constructor -- Understanding inheritance linearization -- Creating abstract contracts -- Creating interfaces -- Creating custom reusable libraries -- Using libraries with - using...for directive -- Summary -- Questions -- Section 2: Deep Dive into Development Tools -- Chapter 4: Learning MetaMask and Remix -- Technical requirements -- Using the MetaMask plugin -- Installing and setting up the MetaMask plugin -- Connecting to different Ethereum networks -- Getting test ether from faucets -- Other features of the MetaMask plugin -- Using the Remix Solidity IDE -- The Remix IDE overview -- Compiler tools present under the Compile tab -- Understanding the Run tab -- Selecting the environment to connect with ; Choosing different wallet accounts -- Transaction parameters -- Selecting the contract to use -- Using deploy and attach -- Deploying a contract -- Initiating a transaction to execute the function -- Initiating a call to a view function and state variables -- Connecting the contract folder using remixd -- Setting up a local instance of the Remix IDE -- Using the blockchain explorer at etherscan.io -- Ethereum wallet software -- Using myetherwallet.com -- Summary -- Questions -- Chapter 5: Using Ganache and the Truffle Framework -- Technical requirements -- Local blockchain with Ganache -- Starting a local blockchain -- Creating workspaces for projects -- Ganache advance configuration -- The command-line version of Ganache -- Understanding Truffle framework -- Setting up a Truffle project -- Truffle configuration files -- Configuring the Solidity compiler -- Configuring networks -- Choosing which blockchain client to use -- Personal blockchain client -- Running blockchain nodes -- Using Infura -- Writing contract migration scripts -- Trigger migration using the migrate option -- Sample migration script -- Using artifacts.require() to get the contract instance -- Using module.exports -- Deployer -- Network considerations -- Available accounts -- Writing test cases -- Writing test cases in JavaScript using Mocha -- Writing test cases in Solidity -- Debug transactions -- Summary -- Questions -- Chapter 6: Taking Advantage of Code Quality Tools -- Technical requirements -- Using the surya tool -- Installing surya -- Using surya describe -- Generating an inheritance graph -- Generating a function call graph -- Parsing contracts -- Generating function traces -- Listing inheritance dependencies -- Generating the markdown report -- Understanding Solidity linters -- Using the solhint linter -- Installing the solhint linter -- Using solhint ; Using the ethlint linter -- Installing ethlint -- Using solium -- The solidity-coverage tool -- Installing solidity-coverage -- Using solidity-coverage -- Summary -- Questions -- Section 3: Mastering ERC Standards and Libraries -- Chapter 7: ERC20 Token Standard -- Technical requirements -- Overview of the ERC20 token standard -- Use of ERC20 in crowdfunding -- The motivation behind the ERC20 standard -- ERC20 standard API -- ERC20 implementation -- Contract state variables -- The balances variable stores account balance -- The allowed variable stores approved balances -- The totalSupply variable stores the total token supply -- The transfer function -- Difference between the ether and token transfer functions -- Token transfer does not notify the contact -- Tokens can be locked -- The transfer transaction details -- The approve function -- Front-running attack on the approve function -- Preventing a front-running attack -- The transferFrom function -- Two-step process for contracts -- The allowance function -- The balanceOf function -- The totalSupply function -- Events -- The Transfer event -- The Approval event -- Optional functions -- The name function -- The symbol function -- The decimals function -- Advanced functions -- The increaseApproval function -- The decreaseApproval function -- Summary -- Questions -- Chapter 8: ERC721 Non-Fungible Token Standard -- Technical requirements -- Overview of the ERC721 NFT standard -- The ERC721 NFT standard API interface -- Understanding the ERC721 implementation -- ERC721 inherits from IERC721 and ERC165 -- ERC721 inherits from ERC165 -- ERC721 inherits from IERC721 -- Understanding ERC721 state variables -- Token owner mapping kept in _tokenOwner -- Approved address mapping kept in _tokenApprovals -- The number of tokens per owner kept in _ownedTokensCount -- Operator approvals kept in _operatorApprovals ; The ERC165 interface code for the ERC721, _INTERFACE_ID_ERC721


Tidsskrift

Artiklen er en del af

Artiklerne i  handler ofte om

Artikler med samme emner

Fra


Artikler

Alle registrerede artikler fordelt på udgivelser

...

...

...

...

...