Solidity
Solidity
Ajinkya Rajguru
Deliverable 4
SJSU: FALL 2022
CS 297
Dr. Chris Pollett
Introduction
• Object Oriented high level language.
• Main purpose: Implementing smart contracts
• Written in .sol files
• Similar to Javascript
• Statically typed
Smart Contracts
• An account present on a blockchain network which is controlled by
code.
• Components of a contract account –
1. Balance – Amount of ether the account owns
2. Storage – Data storage for the contract (depends on the application)
3. Code – Machine code for the contract
Solidity
1. Create contract definition using solidity
2. It is passed to the Solidity compiler
3. The compiler gives out two separate files –
1. Byte Code which is ready for deployment – deployed into Ethereum
network
2. Application Binary Interface (ABI) – Used to interact with deployed smart
contracts ( example using Javascript for .js applications )
Remix IDE for
Solidity [3]
• A web-based IDE to write .sol
contracts
• Contains an inbuild solidity
compiler and an editor
• Great for small contracts
• Also contains a mock
Ethereum network to deploy
and test contracts
• Basic flow of deploying a
contract:
Solidity
1. Common function types include –
1. Access modifiers – public and private
2. Return type – View and Constant: The function returns data and does not modify the
contracts data.
3. Pure – Function will not modify or read the contracts data
4. Payable – This function can include an ether along with its call.
Solidity run and deploy configuration
• Sending Transactions –
• Sending a transaction to a function can include modifying the contract data
which returns the transaction hash.
• Takes time to execute and costs money
References
[1] https://docs.soliditylang.org/en/v0.8.17/introduction-to-smart-
contracts.html#simple-smart-contract
[2] https://www.udemy.com/share/1013Fs3@Qax1kH8XyDPQcM-
COaQ_hYkoQetC7yzJJa_KJQC1oKYYhJXWlDonqhJw9-eXS_6-2Q==/
[3]
https://remix.ethereum.org/#optimize=false&runs=200&evmVersion=n
ull&version=soljson-v0.4.17+commit.bdeb9e52.js&language=Solidity
[4] https://coinguides.org/ethereum-unit-converter-gwei-ether/
[5] https://github.com/djrtwo/evm-opcode-gas-costs