Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Ethereum Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
Ethereum Cookbook

Ethereum Cookbook

By : Manoj P R
close
close
Ethereum Cookbook

Ethereum Cookbook

By: Manoj P R

Overview of this book

Ethereum and Blockchain will change the way software is built for business transactions. Most industries have been looking to leverage these new technologies to gain efficiencies and create new business models and opportunities. The Ethereum Cookbook covers various solutions such as setting up Ethereum, writing smart contracts, and creating tokens, among others. You’ll learn about the security vulnerabilities, along with other protocols of Ethereum. Once you have understood the basics, you’ll move on to exploring various design decisions and tips to make your application scalable and secure. In addition to this, you’ll work with various Ethereum packages such as Truffle, Web3, and Ganache. By the end of this book, you’ll have comprehensively grasped the Ethereum principles and ecosystem.
Table of Contents (13 chapters)
close
close

Installing a solidity compiler

You have multiple options when it comes to compiling smart contracts written in solidity. In this recipe, you will learn about installing a solidity compiler and using it to compile your smart contract.

Getting ready

If you are using macOS, you will need homebrew to install the binary compiler. There are other options, such as using npm or docker, which require Node.js and Docker, respectively, installed on your machine.

How to do it...

  1. If you are in Ubuntu, use ppa to install the compiler by running the following command:
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc
  1. If you are using macOS, install the compiler using brew:
brew update
brew tap ethereum/ethereum
brew install solidity
  1. Verify the installation with the following command:
solc --version
  1. Use this command to compile a contract and print the binary:
solc --bin SampleContract.sol
  1. You want to get some of the more advanced output from solc:
solc -o outDirectory --bin --ast --asm --abi --opcodes SampleContract.sol

We can configure it using these provided flags:

  • --ast: Abstracts the syntax trees of source files
  • --asm: EVM assembly of the contracts
  • --abi: ABI specification of the contracts
  • --opcodes: Opcodes of the contracts

You can get the complete list of operations supported by the solc compiler by running solc --help.

There's more...

There is also a JavaScript-based solidity compiler available for you to use. You can install SolcJS using npm. The solc-js project is derived from the C++ solc project and can be used in JavaScript projects directly:

npm install -g solc

To see all the supported features, run the following command:

solcjs --help
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Ethereum Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon