Professional Documents
Culture Documents
Unit 4 BC
Unit 4 BC
Unit 4 BC
Associate Professor
Dept. of CS&E
Sri Jayachamarajendra College of Engineering
JSS Science and Technology University
• Executable code
• Turing Complete
• Function like an external account
Hold funds
Can interact with other accounts and smart contracts
Contain code
• Can be called through transactions
Savings
Smart contracts remove the intermediaries to handle
transactions , their associated time delays and fees.
1. Autonomy
2. Decentralisation
3. Auto sufficiency(rem:auto)
contract Escrow {
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function refundToBuyer() {
if(msg.sender == seller || msg.sender == arbiter) {
buyer.transfer(this.balance);
}
}
}
Dr Prasanna B T, Assoc Prof, Dept of CSE, SJ
CE, Mysuru
Uses of smart contracts
Insurance
Last but not the least, bug bounty programs are also very
efficient to secure smart contracts..
Dr Prasanna B T, Assoc Prof, Dept of CSE, SJ
CE, Mysuru
Understand the Use case :
Use case of smart contracts should be clear before
development is started, the developer should gather all
Manual Testing
In this phase smart contract should be tested on test-net
(Rinkeby/Ropsten), all the transaction and state changes
should be recorded to verify that the smart contract’s
behavior is the same as that intend to be.
Ref: https://medium.com/quillhash/life-cycle-of-smart-contract-development-8929fa073b7f
Test Coverage:
Solidity-coverage
Linters and Formatters:
Linters improve the code quality.
Solcheck, Solhint, Solium, Prettier Solidity Plugin
Dr Prasanna B T, Assoc Prof, Dept of CSE, SJ
CE, Mysuru
Dr Prasanna B T, Assoc Prof, Dept of CSE, SJ
CE, Mysuru
B. Smart Contract Programming
Serpent
Serpent is a language similar to Python which can be used to develop
contracts and compile to EVM bytecode. It is intended to be maximally clean
and simple, combining many of the efficiency benefits of a low-level language
with ease-of-use in programming style, and at the same time adding special
domain-specific features for contract programming. Serpent is compiled
using LLL.
• Serpent EVM compiler
Dr Prasanna B T, Assoc Prof, Dept of CSE, SJ
CE, Mysuru
B. Smart Contract Programming
Atom Ethereum interface - Plugin for the Atom editor that features
syntax highlighting, compilation and a runtime environment (requires
backend node).
Atom Solidity Linter - Plugin for the Atom editor that provides Solidity
linting.
Vim Solidity - Plugin for the Vim editor providing syntax highlighting.
Vim Syntastic - Plugin for the Vim editor providing compile checking.
contract Example {
uint value;
var logIncrement =
OtherExample.LogIncrement({sender: userAddress,
uint value});
logIncrement.watch(function(err, result) {
// do something with result
})
Interact &
Create Fund Develop Compile Sign &
Account Account Deploy Test
Interact &
Create Fund Develop Compile Sign &
Account Account Deploy Test
Interact &
Create Fund Develop Compile Sign &
Account Account Deploy Test
• From friends
• Faucet
• Exchanges (for public blockchain)
Interact &
Create Fund Develop Compile Sign &
Account Account Deploy Test
Interact &
Create Fund Develop Compile Sign &
Account Account Deploy Test
Bytecodes Connector*
Interact
Create Fund Develop Compile Sign &
Account Account Deploy &
Test
TestRPC/TestChain
• Local development or Test Blockchain
• https://github.com/ethereumjs/testrpc
Hard forks and soft forks are essentially the same in the sense that
when a cryptocurrency platform's existing code is changed, an old
version remains on the network while the new version is created.
With a soft fork, only one blockchain will remain valid as users adopt
the update. Whereas with a hard fork, both the old and new
blockchains exist side by side, which means that the software must be
updated to work by the new rules. Both forks create a split, but a hard
fork creates two blockchains and a soft fork is meant to result in one.
Considering the differences in security between hard and soft forks,
almost all users and developers call for a hard fork, even when a soft
fork seems like it could do the job. Overhauling the blocks in a
blockchain requires a tremendous amount of computing power, but
the privacy gained from a hard fork makes more sense than using a
soft fork.
Dr Prasanna B T, Assoc Prof, Dept of CSE, SJ
CE, Mysuru
Dr Prasanna B T, Assoc Prof, Dept of CSE, SJ
CE, Mysuru
Dr Prasanna B T, Assoc Prof, Dept of CSE, SJ
CE, Mysuru