This document provides an overview of blockchain and smart contracts. It discusses Ethereum concepts like accounts, contracts, and messages. It also covers installing the Ethereum test network and Truffle development environment to create and test a simple smart contract that returns the string "Hello World!".
"Programming Smart Contracts on Ethereum" by Anatoly Ressin from AssistUnion ...Dace Barone
?
He will briefly cover infrastructure of the Ethereum platform, smart contract execution principles including the "gas economics".
High-level programming language for smart contracts Solidity will be presented with practical examples.
In the conclusion we will speak about common problems that could be solved in our society using smart contracts, and why it is worth to learn smart contract programming now.
Anatoly is a Senior Software Developer at C.T.Co, Co-founder at AssistUnion, Board Member of Latvian Blockchain Association. He is a TSI ex-lecturer with more than a decade experience in teaching functional and logic programming and compiler design. Anatoly is a crypto-currency and blockchain enthusiast since 2011
Hands on with smart contracts 2. Presentation for the Blockchain Applications...Gene Leybzon
?
This document provides an overview of blockchain and smart contracts. It discusses Ethereum concepts like accounts, contracts, calls and messages. It also covers Solidity, the most popular smart contract programming language used for Ethereum. The hands-on section demonstrates how to set up a development environment with Truffle, deploy a sample "Hello World" smart contract to the Ethereum test network, and test it.
This document provides an introduction to blockchain, smart contracts, and the Solidity programming language. It discusses why blockchain is significant, defines key blockchain concepts like blocks and decentralized consensus, and compares blockchain to traditional databases. It also introduces smart contracts and Solidity, provides an example smart contract, and outlines key Solidity concepts like accounts, contracts, and calls/messages. The document concludes with information on developing and testing smart contracts.
Accessing decentralized finance on Ethereum blockchainGene Leybzon
?
This document provides an overview of decentralized finance (DeFi) applications and decentralized exchanges (DEX) on the Ethereum blockchain. It describes how DEXes like Uniswap allow users to swap tokens without a centralized intermediary by interacting directly with smart contracts. The key components that enable this include ERC-20 tokens, automated market makers like Uniswap that provide liquidity, and interfaces like MetaMask that allow interacting with smart contracts from a web interface. Overall, the document serves as an introduction to accessing and using DEXes as an alternative to centralized cryptocurrency exchanges.
This document provides an overview of Ethereum smart contracts, including how to compile and deploy contracts manually or using an online compiler. It describes contract components like state, functions, and modifiers. It also covers gas, transactions, addresses, and common pitfalls around things like external calls and shared state.
This document provides an overview of decentralized exchanges (DEXs) like Uniswap, including key metrics on total value locked in DeFi protocols and the growth of DEX volume. It explains the core components that power Uniswap, such as the factory contract that creates trading pairs, the pair contract that handles token swaps, and mechanisms for minting/burning liquidity. Finally, it demonstrates how to interact programmatically with Uniswap through its router contract to get price quotes, swap tokens, and integrate token trading functionality into smart contracts.
Hands-on introduction to blockchain technologies.
First, basic concepts as peer-to-peer networks, mining and distributed consens are introduced basd on the Bitcoin protocol. Next smart contracts are discussed for the Ethereum protocol and demonstrated using a local/private blockchain.
The session concludes with a live demo of the interaction of a Java based classical business application with a smart contract running in the Ethereum network.
The goal of the session is to provide a meaningful background of blockchain technologies in genral and to enable developers to start exploring Ethereum and smart contracts within a few hours.
The proposed development setup is oriented towards Java developers and contains Docker images for the Geth and TestRPC Ethereum clients that can be run locally. To access Ethereum from Java the web3j Java library is used. The business application that integrates with the smart contracts is built with the Eclipse Scout framework.
際際滷s have been created by @ZimMatthias for the JUG Switzerland session on May 22, 2017 https://www.jug.ch/html/events/2017/blockchain_ethereum.html
Ethereum is a decentralized platform that runs smart contracts. It uses a blockchain and cryptocurrency called Ether. Smart contracts are programs that run exactly as programmed without downtime, censorship, fraud or third party interference. They are written in Solidity and run on the Ethereum Virtual Machine. Remix is an IDE used to write, deploy and test smart contracts. It provides different environments like JavaScript VM, injected web3 and web3 provider to interact with local or remote Ethereum networks.
The document discusses blockchain security. It begins by defining what a blockchain is - a shared digital ledger that records transactions in a decentralized peer-to-peer network. It then discusses several key aspects of blockchain security including cryptography techniques like SHA-256 that secure the data, the computational power of the network that acts as a deterrent to attacks, and vulnerabilities like smart contract bugs that still need to be addressed. Overall the document conveys that blockchain security is strong due to its design but also that more work is needed to develop tools and best practices as the technology continues to evolve.
Bitcoin: A Peer-to-Peer Electronic Cash System
Satoshi Nakamoto
satoshin@gmx.com
www.bitcoin.org
Abstract.
A purely peer-to-peer version of electronic cash would allow online
payments to be sent directly from one party to another without going through a
financial institution. Digital signatures provide part of the solution, but the main
benefits are lost if a trusted third party is still required to prevent double-spending.
We propose a solution to the double-spending problem using a peer-to-peer network.
The network timestamps transactions by hashing them into an ongoing chain of
hash-based proof-of-work, forming a record that cannot be changed without redoing
the proof-of-work. The longest chain not only serves as proof of the sequence of
events witnessed, but proof that it came from the largest pool of CPU power. As
long as a majority of CPU power is controlled by nodes that are not cooperating to
attack the network, they'll generate the longest chain and outpace attackers. The
network itself requires minimal structure. Messages are broadcast on a best effort
basis, and nodes can leave and rejoin the network at will, accepting the longest
proof-of-work chain as proof of what happened while they were gone.
This presentation is part of New Product Developers (NPD) meetup regularly conducted by Divum. In this session, we covered gentle introduction to blockchain to running a truly decentralised Pizza ordering application built using solidity on ethereum.
Blockchain , Deploying your first smart contract to azure ethereum blockchain.
際際滷s from my session in "Global Azure Bootcamp Chandigarh"
Presentation starts with basic terms like transactions , ledger and contracts. Talks about what is blockchain and ethereum and concludes with deployment of a smart contract to azure ethereum blockchain.
1) Algorand smart contracts can be written in TEAL or PyTeal and deployed to the Algorand blockchain.
2) PyTeal is a Python library that compiles Python code into TEAL bytecode that can be run as smart contracts on Algorand.
3) Smart contracts have access to transaction properties, can call other contracts, and read from and write to global state stored on the blockchain.
Understanding Algorand's smart contract language Vanessa Lo?i?
?
This document provides an overview of Algorand smart contracts, including stateless and stateful contracts, the TEAL smart contract language, and tools for developing smart contracts like PyTeal and Reach. It discusses stateless contract usages like escrows and recurring payments. For stateful contracts, it explains how they have global and local state and how application transactions interact with them. The document also covers the TEAL stack architecture, opcodes, reading transaction properties, and atomic transactions. It provides examples of programming patterns like branching, asset checks, and reading/writing local state. Finally, it discusses options for simplifying smart contract development.
Blockchain is the technology that powers Bitcoin, allowing for a decentralized digital currency. Ethereum builds on this concept by enabling decentralized applications and smart contracts to be built and run on its blockchain. In Ethereum, smart contracts are written in the Solidity programming language and deployed to the Ethereum Virtual Machine, where they can store data and transact in the native cryptocurrency, Ether. Developers must be careful when writing smart contracts due to the potential for bugs to have costly consequences.
Here are the subnet assignments for the given network:
NETWORK NUMBER NODE ADDRESSES BROADCAST ADDRESS
200.31.192.0 Reserved None
200.31.192.8 .9-.17 200.31.192.18
200.31.192.32 .33-.39 200.31.192.40
200.31.192.64 .65-.66 200.31.192.67
200.31.192.128 .129-.156 200.31.192.157
200.31.192.192 .193-.216 200.31.192.217
Basics you need to know about Solidity and how it works. Learn the simple way of building a smart contract in Solidity. Tools that can be used with Solidity.
The document discusses computer networking and the structure of an introductory course on the topic. It provides an overview of topics that will be covered, including host behavior, building a network, and practicing configurations. The course evaluations and organization are also outlined.
This set of slides is about Ethereum Blockchain and and introduction to Ethereum Smart Contracts. Arguments covered:
- Ethereum chain
- Ethereum nodes
- Solidity language
- Truffle suite
- Dapps development principles
Presentation of 05/30/2019 in University of Turin
This document describes Fog, a Pharo client for the Ethereum blockchain that provides a living programming environment. Fog allows users to connect to Ethereum, query and create transactions and smart contracts. It features first-class navigation of accounts, blocks, transactions and contracts. Contracts can be mirrored and proxied automatically in Pharo for inspection and development support. Fog demonstrates navigating and inspecting blocks, transactions, and sample contract source code and structs. Future work includes finishing session management, adding events support, and improving the AST definition.
A living programming environment for blockchainPharo
?
This document describes Fog, a Pharo client for the Ethereum blockchain that provides a living programming environment. Fog allows users to connect to Ethereum, query and create transactions and smart contracts. It features first-class navigation of accounts, blocks, transactions and contracts. Contracts can be mirrored and inspected in Pharo. The goal is for Fog to provide a state-of-the-art interactive development environment for the Ethereum blockchain. Future work includes improving session management and adding support for events.
This document provides an overview of Remix IDE, Solidity, and smart contract development and deployment. It discusses key concepts like smart contract compilation, the difference between mainnet and testnet, and how MetaMask can be used to deploy contracts. It also summarizes data types in Solidity like integers, variables, arrays, loops, and if/else statements. The document is an introduction to building and testing smart contracts using Remix IDE and the Solidity programming language on Ethereum.
A document describes using the radio and simulating TinyOS applications with TOSSIM. It discusses defining message structures, implementing radio communication using interfaces like Packet and AMSend, and simulating applications by specifying topologies, noise models, and debugging channels. An example application counts over a timer and broadcasts the counter using the radio. It can be simulated in TOSSIM by configuring 3 motes - one acts as a sink and receives periodic messages from sensors reporting temperature and humidity data.
Hands-on introduction to blockchain technologies.
First, basic concepts as peer-to-peer networks, mining and distributed consens are introduced basd on the Bitcoin protocol. Next smart contracts are discussed for the Ethereum protocol and demonstrated using a local/private blockchain.
The session concludes with a live demo of the interaction of a Java based classical business application with a smart contract running in the Ethereum network.
The goal of the session is to provide a meaningful background of blockchain technologies in genral and to enable developers to start exploring Ethereum and smart contracts within a few hours.
The proposed development setup is oriented towards Java developers and contains Docker images for the Geth and TestRPC Ethereum clients that can be run locally. To access Ethereum from Java the web3j Java library is used. The business application that integrates with the smart contracts is built with the Eclipse Scout framework.
際際滷s have been created by @ZimMatthias for the JUG Switzerland session on May 22, 2017 https://www.jug.ch/html/events/2017/blockchain_ethereum.html
Ethereum is a decentralized platform that runs smart contracts. It uses a blockchain and cryptocurrency called Ether. Smart contracts are programs that run exactly as programmed without downtime, censorship, fraud or third party interference. They are written in Solidity and run on the Ethereum Virtual Machine. Remix is an IDE used to write, deploy and test smart contracts. It provides different environments like JavaScript VM, injected web3 and web3 provider to interact with local or remote Ethereum networks.
The document discusses blockchain security. It begins by defining what a blockchain is - a shared digital ledger that records transactions in a decentralized peer-to-peer network. It then discusses several key aspects of blockchain security including cryptography techniques like SHA-256 that secure the data, the computational power of the network that acts as a deterrent to attacks, and vulnerabilities like smart contract bugs that still need to be addressed. Overall the document conveys that blockchain security is strong due to its design but also that more work is needed to develop tools and best practices as the technology continues to evolve.
Bitcoin: A Peer-to-Peer Electronic Cash System
Satoshi Nakamoto
satoshin@gmx.com
www.bitcoin.org
Abstract.
A purely peer-to-peer version of electronic cash would allow online
payments to be sent directly from one party to another without going through a
financial institution. Digital signatures provide part of the solution, but the main
benefits are lost if a trusted third party is still required to prevent double-spending.
We propose a solution to the double-spending problem using a peer-to-peer network.
The network timestamps transactions by hashing them into an ongoing chain of
hash-based proof-of-work, forming a record that cannot be changed without redoing
the proof-of-work. The longest chain not only serves as proof of the sequence of
events witnessed, but proof that it came from the largest pool of CPU power. As
long as a majority of CPU power is controlled by nodes that are not cooperating to
attack the network, they'll generate the longest chain and outpace attackers. The
network itself requires minimal structure. Messages are broadcast on a best effort
basis, and nodes can leave and rejoin the network at will, accepting the longest
proof-of-work chain as proof of what happened while they were gone.
This presentation is part of New Product Developers (NPD) meetup regularly conducted by Divum. In this session, we covered gentle introduction to blockchain to running a truly decentralised Pizza ordering application built using solidity on ethereum.
Blockchain , Deploying your first smart contract to azure ethereum blockchain.
際際滷s from my session in "Global Azure Bootcamp Chandigarh"
Presentation starts with basic terms like transactions , ledger and contracts. Talks about what is blockchain and ethereum and concludes with deployment of a smart contract to azure ethereum blockchain.
1) Algorand smart contracts can be written in TEAL or PyTeal and deployed to the Algorand blockchain.
2) PyTeal is a Python library that compiles Python code into TEAL bytecode that can be run as smart contracts on Algorand.
3) Smart contracts have access to transaction properties, can call other contracts, and read from and write to global state stored on the blockchain.
Understanding Algorand's smart contract language Vanessa Lo?i?
?
This document provides an overview of Algorand smart contracts, including stateless and stateful contracts, the TEAL smart contract language, and tools for developing smart contracts like PyTeal and Reach. It discusses stateless contract usages like escrows and recurring payments. For stateful contracts, it explains how they have global and local state and how application transactions interact with them. The document also covers the TEAL stack architecture, opcodes, reading transaction properties, and atomic transactions. It provides examples of programming patterns like branching, asset checks, and reading/writing local state. Finally, it discusses options for simplifying smart contract development.
Blockchain is the technology that powers Bitcoin, allowing for a decentralized digital currency. Ethereum builds on this concept by enabling decentralized applications and smart contracts to be built and run on its blockchain. In Ethereum, smart contracts are written in the Solidity programming language and deployed to the Ethereum Virtual Machine, where they can store data and transact in the native cryptocurrency, Ether. Developers must be careful when writing smart contracts due to the potential for bugs to have costly consequences.
Here are the subnet assignments for the given network:
NETWORK NUMBER NODE ADDRESSES BROADCAST ADDRESS
200.31.192.0 Reserved None
200.31.192.8 .9-.17 200.31.192.18
200.31.192.32 .33-.39 200.31.192.40
200.31.192.64 .65-.66 200.31.192.67
200.31.192.128 .129-.156 200.31.192.157
200.31.192.192 .193-.216 200.31.192.217
Basics you need to know about Solidity and how it works. Learn the simple way of building a smart contract in Solidity. Tools that can be used with Solidity.
The document discusses computer networking and the structure of an introductory course on the topic. It provides an overview of topics that will be covered, including host behavior, building a network, and practicing configurations. The course evaluations and organization are also outlined.
This set of slides is about Ethereum Blockchain and and introduction to Ethereum Smart Contracts. Arguments covered:
- Ethereum chain
- Ethereum nodes
- Solidity language
- Truffle suite
- Dapps development principles
Presentation of 05/30/2019 in University of Turin
This document describes Fog, a Pharo client for the Ethereum blockchain that provides a living programming environment. Fog allows users to connect to Ethereum, query and create transactions and smart contracts. It features first-class navigation of accounts, blocks, transactions and contracts. Contracts can be mirrored and proxied automatically in Pharo for inspection and development support. Fog demonstrates navigating and inspecting blocks, transactions, and sample contract source code and structs. Future work includes finishing session management, adding events support, and improving the AST definition.
A living programming environment for blockchainPharo
?
This document describes Fog, a Pharo client for the Ethereum blockchain that provides a living programming environment. Fog allows users to connect to Ethereum, query and create transactions and smart contracts. It features first-class navigation of accounts, blocks, transactions and contracts. Contracts can be mirrored and inspected in Pharo. The goal is for Fog to provide a state-of-the-art interactive development environment for the Ethereum blockchain. Future work includes improving session management and adding support for events.
This document provides an overview of Remix IDE, Solidity, and smart contract development and deployment. It discusses key concepts like smart contract compilation, the difference between mainnet and testnet, and how MetaMask can be used to deploy contracts. It also summarizes data types in Solidity like integers, variables, arrays, loops, and if/else statements. The document is an introduction to building and testing smart contracts using Remix IDE and the Solidity programming language on Ethereum.
A document describes using the radio and simulating TinyOS applications with TOSSIM. It discusses defining message structures, implementing radio communication using interfaces like Packet and AMSend, and simulating applications by specifying topologies, noise models, and debugging channels. An example application counts over a timer and broadcasts the counter using the radio. It can be simulated in TOSSIM by configuring 3 motes - one acts as a sink and receives periodic messages from sensors reporting temperature and humidity data.
Welcome to the March 2025 issue of WIPAC Monthly the magazine brought to you by the LinkedIn Group WIPAC Monthly.
In this month's edition, on top of the month's news from the water industry we cover subjects from the intelligent use of wastewater networks, the use of machine learning in water quality as well as how, we as an industry, need to develop the skills base in developing areas such as Machine Learning and Artificial Intelligence.
Enjoy the latest edition
EXPLORE 6 EXCITING DOMAINS:
1. Machine Learning: Discover the world of AI and ML!
2. App Development: Build innovative mobile apps!
3. Competitive Programming: Enhance your coding skills!
4. Web Development: Create stunning web applications!
5. Blockchain: Uncover the power of decentralized tech!
6. Cloud Computing: Explore the world of cloud infrastructure!
Join us to unravel the unexplored, network with like-minded individuals, and dive into the world of tech!
Air pollution is contamination of the indoor or outdoor environment by any ch...dhanashree78
?
Air pollution is contamination of the indoor or outdoor environment by any chemical, physical or biological agent that modifies the natural characteristics of the atmosphere.
Household combustion devices, motor vehicles, industrial facilities and forest fires are common sources of air pollution. Pollutants of major public health concern include particulate matter, carbon monoxide, ozone, nitrogen dioxide and sulfur dioxide. Outdoor and indoor air pollution cause respiratory and other diseases and are important sources of morbidity and mortality.
WHO data show that almost all of the global population (99%) breathe air that exceeds WHO guideline limits and contains high levels of pollutants, with low- and middle-income countries suffering from the highest exposures.
Air quality is closely linked to the earth¨s climate and ecosystems globally. Many of the drivers of air pollution (i.e. combustion of fossil fuels) are also sources of greenhouse gas emissions. Policies to reduce air pollution, therefore, offer a win-win strategy for both climate and health, lowering the burden of disease attributable to air pollution, as well as contributing to the near- and long-term mitigation of climate change.
Preface: The ReGenX Generator innovation operates with a US Patented Frequency Dependent Load
Current Delay which delays the creation and storage of created Electromagnetic Field Energy around
the exterior of the generator coil. The result is the created and Time Delayed Electromagnetic Field
Energy performs any magnitude of Positive Electro-Mechanical Work at infinite efficiency on the
generator's Rotating Magnetic Field, increasing its Kinetic Energy and increasing the Kinetic Energy of
an EV or ICE Vehicle to any magnitude without requiring any Externally Supplied Input Energy. In
Electricity Generation applications the ReGenX Generator innovation now allows all electricity to be
generated at infinite efficiency requiring zero Input Energy, zero Input Energy Cost, while producing
zero Greenhouse Gas Emissions, zero Air Pollution and zero Nuclear Waste during the Electricity
Generation Phase. In Electric Motor operation the ReGen-X Quantum Motor now allows any
magnitude of Work to be performed with zero Electric Input Energy.
Demonstration Protocol: The demonstration protocol involves three prototypes;
1. Protytpe #1, demonstrates the ReGenX Generator's Load Current Time Delay when compared
to the instantaneous Load Current Sine Wave for a Conventional Generator Coil.
2. In the Conventional Faraday Generator operation the created Electromagnetic Field Energy
performs Negative Work at infinite efficiency and it reduces the Kinetic Energy of the system.
3. The Magnitude of the Negative Work / System Kinetic Energy Reduction (in Joules) is equal to
the Magnitude of the created Electromagnetic Field Energy (also in Joules).
4. When the Conventional Faraday Generator is placed On-Load, Negative Work is performed and
the speed of the system decreases according to Lenz's Law of Induction.
5. In order to maintain the System Speed and the Electric Power magnitude to the Loads,
additional Input Power must be supplied to the Prime Mover and additional Mechanical Input
Power must be supplied to the Generator's Drive Shaft.
6. For example, if 100 Watts of Electric Power is delivered to the Load by the Faraday Generator,
an additional >100 Watts of Mechanical Input Power must be supplied to the Generator's Drive
Shaft by the Prime Mover.
7. If 1 MW of Electric Power is delivered to the Load by the Faraday Generator, an additional >1
MW Watts of Mechanical Input Power must be supplied to the Generator's Drive Shaft by the
Prime Mover.
8. Generally speaking the ratio is 2 Watts of Mechanical Input Power to every 1 Watt of Electric
Output Power generated.
9. The increase in Drive Shaft Mechanical Input Power is provided by the Prime Mover and the
Input Energy Source which powers the Prime Mover.
10. In the Heins ReGenX Generator operation the created and Time Delayed Electromagnetic Field
Energy performs Positive Work at infinite efficiency and it increases the Kinetic Energy of the
system.
Lecture -3 Cold water supply system.pptxrabiaatif2
?
The presentation on Cold Water Supply explored the fundamental principles of water distribution in buildings. It covered sources of cold water, including municipal supply, wells, and rainwater harvesting. Key components such as storage tanks, pipes, valves, and pumps were discussed for efficient water delivery. Various distribution systems, including direct and indirect supply methods, were analyzed for residential and commercial applications. The presentation emphasized water quality, pressure regulation, and contamination prevention. Common issues like pipe corrosion, leaks, and pressure drops were addressed along with maintenance strategies. Diagrams and case studies illustrated system layouts and best practices for optimal performance.
Integration of Additive Manufacturing (AM) with IoT : A Smart Manufacturing A...ASHISHDESAI85
?
Combining 3D printing with Internet of Things (IoT) enables the creation of smart, connected, and customizable objects that can monitor, control, and optimize their performance, potentially revolutionizing various industries. oT-enabled 3D printers can use sensors to monitor the quality of prints during the printing process. If any defects or deviations from the desired specifications are detected, the printer can adjust its parameters in real time to ensure that the final product meets the required standards.
"Zen and the Art of Industrial Construction"
Once upon a time in Gujarat, Plinth and Roofs was working on a massive industrial shed project. Everything was going smoothly!blueprints were flawless, steel structures were rising, and even the cement was behaving. That is, until...
Meet Ramesh, the Stressed Engineer.
Ramesh was a perfectionist. He measured bolts with the precision of a Swiss watchmaker and treated every steel beam like his own child. But as the deadline approached, Ramesh¨s stress levels skyrocketed.
One day, he called Parul, the total management & marketing mastermind.
? Ramesh (panicking): "Parul ma¨am! The roof isn't aligning by 0.2 degrees! This is a disaster!"
? Parul (calmly): "Ramesh, have you tried... meditating?"
? Ramesh: "Meditating? Ma¨am, I have 500 workers on-site, and you want me to sit cross-legged and hum `Om¨?"
? Parul: "Exactly. Mystic of Seven can help!"
Reluctantly, Ramesh agreed to a 5-minute guided meditation session.
? He closed his eyes.
??=? He breathed deeply.
? He chanted "Om Namah Roofaya" (his custom version of a mantra).
When he opened his eyes, a miracle happened!
? His mind was clear.
? The roof magically aligned (okay, maybe the team just adjusted it while he was meditating).
? And for the first time, Ramesh smiled instead of calculating load capacities in his head.
? Lesson Learned: Sometimes, even in industrial construction, a little bit of mindfulness goes a long way.
From that day on, Plinth and Roofs introduced tea breaks with meditation sessions, and productivity skyrocketed!
Moral of the story: "When in doubt, breathe it out!"
#PlinthAndRoofs #MysticOfSeven #ZenConstruction #MindfulEngineering
2. PLAN FOR TODAY
Understand basic Etherium concepts
Install Etherium Test Network
Install truffle code development environment
Create your first contract
Compile
Test on the test network
4. TWO TYPES OF ACCOUNTS
Accou
nt
Externally Owned
(user accounts)
Contra
ctAccount
StorageBalance Code
<>
Externally Owned Account
StorageBalance
Account
StorageBalance Code
<>
Contract
StorageBalance Code
<>
5. CONTRACTS
Contracts are accounts that contain code
Store the state
? Example: account
balances
Serve as external
account with special
access polices
? Example: messaging
service that forwards
only messages when
certain conditions are
met
Mapping - relationship
between users
? Example: mapping
real-world financial
contract to Etherium
contract
Act like a software
library
? Example: return
calculated value
based on message
arguments
6. MESSAGES
Contract A Contract B
Message Call
? Source
? Target
? Data Payload
? Ether
? Gas
? Return Data
Non-contract
Account
Message CallsendTransaction
Call
7. WHAT CONTRACT CAN DO?
Read internal state
? contract
ReadStateDemo {
? uint public state;
? function read() {
? console.log(^State:
"+state);
? }
? }
Modify internal State
? contract
ModStateDemo {
? uint public state;
? function update() {
? state=state+1;
? }
? }
Consume message
? contract
ReadStateDemo {
? uint public state;
? function hi() {
? console.log(^Hello
from: ^ "+msg.sender
+ ^ to ^ + msg.
receiver);
? }
? }
Trigger execution of
another contract
? contract CallDemo {
? function send(address
receiver, uint amount)
public {
? Sent(msg.sender,
receiver, amount);
? }
? }
9. REGISTRARS (ETHEREUM NAME
SERVICE, ENS)
?Send ether to an address in Metamask (soon: MEW, Mist, Bitfinex).
?Use it inside your own contracts to resolve names of other contracts and addresses.
?Store contract ABIs for easy lookup using the ethereum-ens library
?Address of a Swarm site
Use Cases
Registry
Regista
r
Resolve
r
11. GAS
step 1 Default amount of gas to pay for an execution
cycle
stop 0 Nothing paid for the STOP operation
suicide 0 Nothing paid for the SUICIDE operation
sha3 20 Paid for a SHA3 operation
sload 30 Paid for a SLOAD operation
sstore 100 Paid for a normal SSTORE operation
(doubled or waived sometimes)
balance 20 Paid for a BALANCE operation
create 100 Paid for a CREATE operation
call 20 Paid for a CALL operation
memory 1 Paid for every additional word when
expanding memory
txdata 5 Paid for every byte of data or code for a
transaction
transaction 500 Paid for every transaction
Example:
300 CPU cycles = 300 gas units = 0.000006 ETH =
$0.00553
(as of 2/20/2018)
Cost of Gas as in 2018
13. ELEMENTARY DATA TYPES
Data Type Example
uint<M> , M=1,2,4, ´, 256
int<M>, uint, int
Unsigned/signed integer uint256 counter = 1;
address 160-bit value that does not
allow any arithmetic
operations. It is suitable for
storing addresses of
contracts or keypairs
belonging to external
persons
address owner =
msg.sender;
bool Same as uint8 but values are
0 or 1
Bool b = 0;
fixed<M>x<N>
ufixed<M>x<N>
Signed fixed-point decimal
number of M bits
fixed128x19 f = 1.1;
bytes<M>, M=1..32 Binary of M bytes bytes32 n=123;
function Same as bytes24 Function f;
14. ARRAYS
Data Type Example
<type>[M] fixed-length array of fixed-
length type
byte[100]
<type>[] variable-length array of
fixed-length type
byte[]
bytes dynamic sized byte sequence bytes ab;
string dynamic sized Unicode
string
String s = ^String ̄;
fixed<M>x<N>
ufixed<M>x<N>
Signed fixed-point decimal
number of M bits
fixed128x19 f = 1.1;
22. HELLO WORLD CONTRACT
(SOLIDITY CODE)
pragma solidity ^0.4.4;
contract Hello {
function Hello() public {
// constructor
}
function sayHello() public pure returns
(string) {
//console.log("sayHello() function
called...");
return 'Hello World!';
}
}
26. STAY IN TOUCH
Gene Leybzon https://www.linkedin.com/in/leybzon/
https://www.meetup.com/members/90744
20/
https://www.leybzon.com
Editor's Notes
#5: Every account has a persistent key-value store mapping 256-bit words to 256-bit words called storage
#7: Message:?This is contract-to-contract. These are not delayed by mining because they are part of the transaction execution.
Transaction: Like a message, but originates with an externally owned account. It's always a transaction that gets things started, but multiple messages may be fired off to complete the action.
Ethereum also has two modes of execution. These modes are indifferent to the syntax or vernacular in the client that summoned the contract. So, the important things are to know which one is appropriate, and how to select it in your client of choice.
sendTransaction:?Transaction is sent to the network and verified by miners. Sender gets a transaction hash initially since no results are available until after the transaction is mined. These are potentially state-changing.
call:?Transaction is executed locally on the user's local machine which alone evaluates the result. These are read-only and fast. They can't change the blockchain in any way because they are never sent to the network. Most languages/platforms don't have this idea of running the code in either "read-only/dry run/practice" mode and "read-write/real world/sticky" mode.
(https://ethereum.stackexchange.com/questions/12065/what-is-the-difference-between-a-call-message-call-and-a-message)