Ethereum wallet and solidity tutorial
Ethereum wallet and solidity tutorial
Blockchain
Instructor: Dr Umar Janjua BS/MS fall 2024
Topics to be Covered
❏ Introduction to ethereum
❏ Ethereum Wallet
❏ Create Ethereum Wallet
❏ Overview of etherscan.io
❏ Smart Contracts
❏ Introduction to solidity
❏ Run First Smarct in Solidity
Introduction to Ethereum
Ethereum wallets are not physical wallets, but rather software applications that enable users to store, send, and
receive Ethereum. They consist of a public address, which is similar to a bank account number, and a private key,
which is like a password that grants access to the wallet and the associated Ethereum assets.
Wallets are vital for securely storing and managing Ethereum assets. They provide a secure environment for holding
private keys and facilitate the sending and receiving of Ethereum transactions. Without a wallet, it would be
challenging to access, manage, and utilize Ethereum assets effectively.
Types of Ethereum Wallets
Ensuring the security of an Ethereum wallet is Consider using offline storage options, like
paramount. Using a strong password and hardware wallets, to securely store private keys.
enabling two-factor authentication adds an extra Also, be cautious of phishing attacks and malware
layer of security to the wallet. Strong passwords that can compromise wallet security; verifying the
should be unique, complex, and not easily authenticity of websites is essential.
guessable.
Managing and Using an Ethereum Wallet
Ethereum wallets provide features Users can send and receive Users can check wallet balances
such as sending and receiving Ethereum transactions by and transaction history easily
Ethereum transactions, managing entering the recipient's wallet within the wallet interface. Some
multiple wallet addresses, and address, specifying the amount, wallets also allow DApp
interacting with decentralized and confirming the transaction, integration, enabling interaction
applications (DApps) on the which is vital for financial activities with various decentralized
Ethereum blockchain. on the Ethereum network. applications built on the
Ethereum blockchain.
Conclusion and Tips for Ethereum Wallet Usage
Significance of Ethereum Wallets In conclusion, Ethereum wallets are crucial for securely storing and
managing Ethereum assets. They provide a means to securely store, send,
and receive Ethereum assets, essential for interacting with the Ethereum
blockchain.
Guidelines for Safe Management To ensure safety, choose reputable wallet providers, set strong passwords,
enable two-factor authentication, consider offline storage options, and be
cautious of phishing attacks and malware. Regularly update wallet
software and keep backups.
Understanding Smart Contracts
Smart contracts are self-executing contracts with the
terms of the agreement directly written into code. They
automatically execute when predefined conditions are
met, without the need for intermediaries. Smart contracts
are deployed on the blockchain, ensuring transparency,
immutability, and security.
Decentralized
Token
Applications
Standards
Smart Contracts Development and Deployment
1 2 3 4 5 6
Design the contract Implementing the Solidity code compiled Compiled code get Performing various tests Monitoring performance
including defining its functions events, and into bytecode that can be deployed on the on the contract including and detecting abnormal
structure, state, conditions defined in the deployed on the blockchain and make it unit tests, integration usage
variables, functions, and design step blockchain available to the network tests, security tests.
events.
Introduction to Solidity
Solidity is a high level, contract-oriented programming language that is used for writing smart contracts on the
ethereum-compatible blockchain.
● Solidity developed specifically for the ethereum platform and is influenced by C++, python and JavaScript.
● Solidity is designed to provide a simple and secure way to create self-executing contracts that enforce the
rules and conditions of an agreement between parties.
● Solidity contracts are executed on the Ethereum Virtual Machine, which is built into Ethereum blockchain and
allow developers to create decentralized applications and automate the transfer of digital assets based on the
conditions encoded in the contract.
● Supports features such as multiple inheritance, user-defined types, events, modifiers which makes it possible
to write complex, feature-rich smart contracts.
Introduction to Remix Framework for Solidity
Benefits of using the Remix Framework Accessing the Remix Framework online
Inheritance in Solidity allows for code reuse and Additionally, Solidity supports libraries, which are
modularity. Contracts can inherit properties and collections of reusable code that can be deployed
functions from other contracts, creating a independently or used by other contracts. Libraries
hierarchical structure. This promotes code provide a way to share common functionality
organization and reduces redundancy. across multiple contracts, improving code efficiency
and reducing gas costs.
Layout and Structure Solidity Smart Contract
● Contracts in solidity are similar to classes in object-oriented languages.
● Each Contract can contain declarations of
○ Pragma directives
○ State Variables
○ Functions
○ Function Modifiers
○ Events
○ Errors
○ Struct
○ Enum
Contract
● A smart contract is a computer program that automatically executes the terms of a contract when certain
conditions are met.
● Every contract defines its own type. You can implicitly convert contracts to contracts they inherit from.
● Contracts can be explicitly converted to and from the address type.
● If you declare a local variable of contract type (MyContract c), you can call functions on that contract. Take
care to assign it from somewhere that is the same contract type.
● Contracts do not support any operators.
● The members of contract types are the external functions of the contract including any state variables
marked as public
Example of Smart Contract
Pragma
● Used to specify the compiler version for specific solidty file
● You need to add pragma in your all files as its specific to a file
● The pragma version is used as follows:
● Internal: Can only be accessed within the contract and in its subclasses.
● Private: Variable can only be accessed within the contract its defined.
Value Types
Booleans Integers
bool: The possible values are constants true and false. Integers: int / uint: Signed and unsigned integers of various
Operators: sizes.
Address
The address type comes in two flavours, which are largely identical:
● Public: Part of the contract interface and can be either called internally or via message calls.
● Internal: Internal functions can only be accessed from within the current contract or
contracts deriving from it.
● Private: Private functions are like internal ones but they are not visible in
derived contracts.
Variables in Solidity
Variables in Solidity are used to store and manipulate data
within a contract. Solidity supports different types of
variables, including integers, booleans, addresses, strings,
arrays, and more. Variables can be declared at the
contract level or within functions, and their scope
determines where they can be accessed. Understanding
variables and their types is essential for managing data
and implementing the desired functionality in Solidity
smart contracts.
Data Types in Solidity
Solidity offers various data types to handle different kinds
of data in smart contracts. These data types include
integers, booleans, addresses, strings, arrays, mappings,
and more. Each data type has its specific use cases and
properties, enabling developers to manipulate and store
data efficiently. Understanding the different data types in
Solidity is crucial for designing smart contracts that can
handle and process data accurately and securely.
Mapping and Arrays in Solidity
Mapping: A mapping is a key-value store that Arrays: Arrays are ordered collections of elements
associates a value with a unique key, allowing for that can be of the same or different data types.
efficient lookup and retrieval of values. Mappings They allow for storing and accessing multiple values
are commonly used to represent relationships sequentially and can be dynamically or fixed-sized.
between different entities in a smart contract.
Writing your First Solidity Contract
Deploying the contract on the Remix Interacting with the contract through
environment Remix
To run a Solidity contract, you need to deploy it Once the contract is deployed, you can interact
on the Remix environment. Remix provides a with it using Remix. Remix provides a user
deployment feature that allows you to choose the interface for interacting with the functions and
deployment method, such as using JavaScript VM, state variables of the deployed contract. You can
Injected Web3, or connecting to a local blockchain input values, trigger functions, and observe the
network. Select the appropriate deployment changes in the contract's state.
method and follow the instructions provided by
Remix.