Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Key Points 

References

...

https://www.bloomberg.com/news/articles/2021-08-14/bye-bye-miners-how-
ethereum-s-big-change-will-work-quicktake

Ethereum changes coming: POS, shards, lower gas, burn ether pdf

...

https://www.slideshare.net/Synerzip/blockchain-application-development-101

blockchain-application-development-webinar-sweetbridge-190905082233.pdf

...

Networks are different Ethereum environments you can access for development, testing, or production use cases. Your Ethereum account will work across the different networks but your account balance and transaction history won't carry over from the main Ethereum network. For testing purposes, it's useful to know which networks are available and how to get testnet ETH so you can play around with it.

...

a redeemable bitcoin token for ERC-20 wallets w transaction interop

...

Key Concepts

Smart Contract Concepts - EUBOF - 2022

https://www.linkedin.com/search/results/content/?keywords=smart%20contract%20report&sid=XQ(&update=urn%3Ali%3Afs_updateV2%3A(urn%3Ali%3Aactivity%3A6996355023236403200%2CBLENDED_SEARCH_FEED%2CEMPTY%2CDEFAULT%2Cfalse)

eubof-smart-contracts-paper-2022.pdf  link

View file
nameeubof-smart-contracts-paper-2022.pdf
height250

Ethereum Concepts

https://ethereum.org/en/developers/docs/intro-to-ethereum/

Ether Concepts

https://ethereum.org/en/developers/docs/intro-to-ether/

Ethereum Accounts

https://ethereum.org/en/developers/docs/accounts/

Table of Contents

Key Points 


References

Reference_description_with_linked_URLs________________________________Notes_______________________________________________________________
m Ethereum


https://www.ethereum.org/beginners/Ethereum for beginners
https://www.ethereum.org/Ethereum
https://en.wikipedia.org/wiki/EthereumEthereum
https://medium.com/blockchannel/life-cycle-of-an-ethereum-transaction-e5c66bae0f6eEthereum transaction concepts

https://www.linkedin.com/pulse/methods-transferring-ether-between-contracts-solidity-shahzad/

solidity-contract-transfers-linkedin.com-Methods of transferring Ether between the Contracts in Solidity.pdf link

solidity-contract-transfers-linkedin.com-Methods of transferring Ether between the Contracts in Solidity.pdf file

Methods of transferring Ether between the Contracts in Solidity **

Solidity supports several methods of transferring ether between the contracts.


Creating and Deploying Smart Contracts with Solidity-baeldung.com.pdf link

Creating and Deploying Smart Contracts with Solidity-baeldung.com.pdf file

Deprecated - Creating and Deploying Smart Contracts with Solidity - Baeldung








https://bitfalls.com/2018/05/31/what-is-an-ethereum-testnet-and-how-is-it-used/How to use Ethereum testnets

https://www.bloomberg.com/news/articles/2021-08-14/bye-bye-miners-how-
ethereum-s-big-change-will-work-quicktake

Ethereum changes coming: POS, shards, lower gas, burn ether pdf

Ethereum changes coming: POS, shards, lower gas, burn ether


https://hackernoon.com/costs-of-a-real-world-ethereum-contract-2033511b3214Estimated costs of an Ethereum contract - 2017

https://www.slideshare.net/Synerzip/blockchain-application-development-101

blockchain-application-development-webinar-sweetbridge-190905082233.pdf

Blockchain App Development Concepts 101 - slideshare - sweetbridge


https://ethgasstation.info/Gas station - current gas prices to run a transaction ... expensive
https://hackernoon.com/costs-of-a-real-world-ethereum-contract-2033511b3214calculating gas prices
https://ethereum.stackexchange.com/questions/35539/what-is-the-real-price-of-
deploying-a-contract-on-the-mainnet
Costs of a contract deployment
https://entethalliance.org/enterprise-ethereum-alliance-advances-web-3-0-era-public-release-enterprise-ethereum-architecture-stack/EEA
https://entethalliance.org/wp-content/uploads/2018/05/EEA-Architecture-Stack-Spring-2018.pdfEEA stack
https://entethalliance.github.io/trusted-computing/spec.htmlEEA Off-Chain Trusted Computing Spec


testnets
https://www.anyblockanalytics.com/networks/ethereum/ropsten/#:~:
text=Description,
Morden%2C%20the%20first%20Ethereum%20Testnet
.
Ropsten testnet about
for blockchain development testing before deployment
https://ropsten.etherscan.io/Ropsten testnet console
https://ethereum.org/en/developers/docs/networks/

Networks are different Ethereum environments you can access for development, testing, or production use cases. Your Ethereum account will work across the different networks but your account balance and transaction history won't carry over from the main Ethereum network. For testing purposes, it's useful to know which networks are available and how to get testnet ETH so you can play around with it.

https://umbria.network/connect/ethereum-testnet-ropstenConnect metamask to Ropsten testnet




Wallets and tokens


https://drive.google.com/open?id=16YzIZpOCFDTR4E0SW5EZ31sdQViWJhE7

a redeemable bitcoin token for ERC-20 wallets w transaction interop


EEA - Ethereum Enterprise Alliance - permissioned Ethereum
https://entethalliance.org/wp-content/uploads/2022/06/EEA_
Ethereum_Business_Readiness_Report_2022_v1.1_June_29_2022.pdf
EEA readiness report 2022









Key Concepts


Smart Contract Concepts - EUBOF - 2022

https://www.linkedin.com/search/results/content/?keywords=smart%20contract%20report&sid=XQ(&update=urn%3Ali%3Afs_updateV2%3A(urn%3Ali%3Aactivity%3A6996355023236403200%2CBLENDED_SEARCH_FEED%2CEMPTY%2CDEFAULT%2Cfalse)

eubof-smart-contracts-paper-2022.pdf  link


View file
nameeubof-smart-contracts-paper-2022.pdf
height250


Deprecated > Creating and Deploying Smart Contracts with Solidity - Baeldung - Java interface to create, run Solidity Dapps

https://www.baeldung.com/smart-contracts-ethereum-solidity

https://github.com/eugenp/tutorials/tree/master/ethereum


A smart contract is a stand-alone script usually written in
Solidity and compiled into binary or JSON and
deployed to a specific address on the blockchain. In
the same way that we can call a specific URL endpoint of a
RESTful API to execute some logic through an HttpRequest,
we can similarly execute the deployed smart contract at a
specific address by submitting the correct data along with
the necessary Ethereum to call the deployed and compiled
Solidity function.

see a smart contract as a collection of code stored in the blockchain
network that defines conditions to which all parties using the contract agree upon.

Anyone can deploy a smart contract to the decentralized database for a fee proportional to
the storage size of the containing code. Nodes wishing to use the smart contract must
somehow indicate the result of their participation to the rest of the network.

Solidity – which is a Javascript-like language developed specifically for writing
smart contracts. Solidity is statically typed, supports
inheritance, libraries and complex user-defined types among other features.

deployment

solidity compiler turns code into EVM bytecode, which
can then be sent to the Ethereum network as a deployment
transaction. Such deployments have more substantial
transaction fees than smart contract interactions and must
be paid by the owner of the contract.

Remix IDE

We can use Remix, which's currently the best online IDE and it's effortless to use.

execute a contract from a node

run a client ourselves

OR connect to a remote node using a service like Infura.
Infura is the most straightforward option, so we'll request a free access token. Once we sign up, we need to pick the URL
of the Rinkeby test network:
https://rinkeby.infura.io/<token>”.
To be able to transact with the smart contract from Java, we need to use a library called Web3j. Here is the Maven dependency:
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>3.3.1</version>
</dependency>

5.1. Creating a Wallet

5.2. Requesting Ether in the Rinkeby Testnet

5.3. Generating the Smart Contract Wrapper

6. Interacting With the Smart Contract

In our main class, we start by creating a new web3j instance to connect to remote nodes on
the network:

Web3j web3j = Web3j.build(
new
HttpService("https://rinkeby.infura.io/<your_token>"));
We then need to load our Ethereum wallet file:
Credentials credentials = WalletUtils.loadCredentials(
"<password>",
"/path/to/<walletfile>");
Now let's deploy our smart contract:
Greeting contract = Greeting.deploy(
web3j, credentials,
ManagedTransaction.GAS_PRICE, Contract.GAS_LIMIT,
"Hello blockchain world!").send();
Deploying the contract may take a while depending the work in the network. Once is
deployed, we might want to store the address where the contract was deployed. We can
obtain the address this way:
String contractAddress = contract.getContractAddress();
All the transactions made with the contract can be seen in the url:
https://rinkeby.etherscan.io/address/<contract_address>”.
On the other hand, we can modify the value of the smart contract performing a transaction:
TransactionReceipt transactionReceipt = contract.setGreeting("Hello again").send();
Finally, if we want to view the new value stored, we can simply write:
String newValue = contract.greet().send();




Ethereum Concepts

https://ethereum.org/en/developers/docs/intro-to-ethereum/



EVM Concepts


Gimer Cervera

https://www.linkedin.com/posts/gimercervera_ethereum-virtual-machine-evm-deep-dive-activity-7147970421055782914-2kQu?utm_source=share&utm_medium=member_desktop

Last week I posted an article on Medium related to the Ethereum Virtual Machine (EVM) and some insights related to inline assembly. The goal of the material is to explore in detail the EVM and learn how to code more efficient and secure smart contracts. In this post, I'd like to share other inspirational resources so you can improve your knowledge on this exciting field.



EVM Medium article: https://lnkd.in/eiXn-pp2



✅ Andreas Antonopoulos - The Ethereum Virtual Machine: https://lnkd.in/eB2JXDwz



✅ Femboy Capital - A Playdate with the EVM: https://lnkd.in/ezdADJAZ



✅ Solidity Tutorial All About Assembly: https://lnkd.in/eBU75N6x



✅ Openzeppelin - Deconstructing a Solidity Contract: https://lnkd.in/evqRvgs4



✅ Diving Into the Ethereum Virtual Machine: https://lnkd.in/eG6F2YEg



If you want to review more resources, you can find a curated list of articles and videos in my github account: https://lnkd.in/eK_XB-UU



Enjoy!


EVM Deep Dive - Part 1 - artlcle


evm-concepts-p1-2023-medium.com-Ethereum Virtual Machine EVM Deep Dive Part I .pdf.  link

evm-concepts-p1-2023-medium.com-Ethereum Virtual Machine EVM Deep Dive Part I .pdf. file

Image Added




Ether Concepts

https://ethereum.org/en/developers/docs/intro-to-ether/


Ethereum Accounts

https://ethereum.org/en/developers/docs/accounts/

Ethereum has two account types:

  • Externally-owned account (EOA) – controlled by anyone with the private keys
  • Contract account – a smart contract deployed to the network, controlled by code. Learn about smart contracts

Both account types have the ability to:

  • Receive, hold and send ETH and tokens
  • Interact with deployed smart contracts

Key differences on EOA vs CA

Externally-owned

  • Creating an account costs nothing
  • Can initiate transactions
  • Transactions between externally-owned accounts can only be ETH/token transfers
  • Made up of a cryptographic pair of keys: public and private keys that control account activities

Contract

  • Creating a contract has a cost because you're using network storage
  • Can only send transactions in response to receiving a transaction
  • Transactions from an external account to a contract account can trigger code which can execute many different actions, such as transferring tokens or even creating a new contract
  • Contract accounts don't have private keys. Instead, they are controlled by the logic of the smart contract code


Account Abstraction overview

https://blog.pantherprotocol.io/ethereum-account-abstraction-everything-you-need-to-know/

Image Added

Externally Owned Accounts (EOA)

A 'regular' Ethereum account with which you can initiate transactions, send, and receive ETH or any other Ethereum-based token (ERC-20, ERC-721, etc), and interact with smart contracts is an externally owned account (EOA). The average Ethereum user owns an EOA, and through wallets, the account interacts with the blockchain.

Externally owned Ethereum accounts cost nothing to create, as they incur no storage requirements. They are simple accounts unassociated with data storage or code. EOAs are the only Ethereum account type with private keys, and these private keys have control over transaction signing. Also, when two EOAs interact, they can only initiate ETH or token transfers.

In summary, an externally owned Ethereum account has a public address and a private key, can initiate transactions and interact with smart contracts, requires no storage, and is represented on the EVM with an empty code string.

Contract Accounts (CA)

Contract accounts are a tad different from EOAs, as a code written on the EVM controls their activities. They are also commonly known as smart contracts. This code, once written, cannot be altered and will define the nature of transactions the contract account can complete. CAs do not initiate transactions, unlike their EOA counterparts. Instead, they can only send transactions in response to a transaction received.

For example, if you send a token to a contract account to exchange said for ETH tokens, the CA receives your transaction and, through its code, sends the corresponding amount of ETH to your address. Apart from being able to transfer tokens, contract accounts can also create new contracts.

Since CAs are controlled by their code's logic, they do not have private keys. Also, contract accounts use network storage. As such, creating them comes at a cost. The nonce of a contract account counts the number of contracts every specific CA has created.

What is Ethereum account abstraction?

Data abstraction in computer science translates to hiding information to increase efficiency. For example, a software developer can learn how to write a compiler or understand the mechanisms between the compiler, processors, or memory functions when building with high-level programming languages. Data abstraction keeps the 0s and 1s underneath, allowing developers to work directly with more friendly languages, saving time and allowing for more complex operations.

In the case of Ethereum, account abstraction seeks to eliminate the existence of two types of accounts by unifying them. Thus, a single contract account will be empowered to transact with tokens and create contracts, unifying both account types. Instead of being separate account types, both EOAs and CAs will fall under a single type.

With this change, transactions will move off the blockchain and onto the EVM, eliminating the distinction between accounts. Let’s look into what exactly motivates this idea, whether it is truly achievable, and what are its benefits.


AN ACCOUNT EXAMINED

Ethereum accounts have four fields:

  • nonce – A counter that indicates the number of transactions sent from the account. This ensures transactions are only processed once. In a contract account, this number represents the number of contracts created by the account.
  • balance – The number of wei owned by this address. Wei is a denomination of ETH and there are 1e+18 wei per ETH.
  • codeHash – This hash refers to the code of an account on the Ethereum virtual machine (EVM). Contract accounts have code fragments programmed in that can perform different operations. This EVM code gets executed if the account gets a message call. It cannot be changed, unlike the other account fields. All such code fragments are contained in the state database under their corresponding hashes for later retrieval. This hash value is known as a codeHash. For externally owned accounts, the codeHash field is the hash of an empty string.
  • storageRoot – Sometimes known as a storage hash. A 256-bit hash of the root node of a Merkle Patricia trie that encodes the storage contents of the account (a mapping between 256-bit integer values), encoded into the trie as a mapping from the Keccak 256-bit hash of the 256-bit integer keys to the RLP-encoded 256-bit integer values. This trie encodes the hash of the storage contents of this account, and is empty by default.

A diagram showing the make up of an accountImage AddedDiagram adapted from Ethereum EVM illustrated

EXTERNALLY-OWNED ACCOUNTS AND KEY PAIRS

An account is made up of a cryptographic pair of keys: public and private. They help prove that a transaction was actually signed by the sender and prevent forgeries. Your private key is what you use to sign transactions, so it grants you custody over the funds associated with your account. You never really hold cryptocurrency, you hold private keys – the funds are always on Ethereum's ledger.

This prevents malicious actors from broadcasting fake transactions because you can always verify the sender of a transaction.

If Alice wants to send ether from her own account to Bob’s account, Alice needs to create a transaction request and send it out to the network for verification. Ethereum’s usage of public-key cryptography ensures that Alice can prove that she originally initiated the transaction request. Without cryptographic mechanisms, a malicious adversary Eve could simply publicly broadcast a request that looks something like “send 5 ETH from Alice’s account to Eve’s account,” and no one would be able to verify that it didn’t come from Alice.

ACCOUNT CREATION

When you want to create an account most libraries will generate you a random private key.

A private key is made up of 64 hex characters and can be encrypted with a password.

Example:

fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036415f

The public key is generated from the private key using the Elliptic Curve Digital Signature Algorithm. You get a public address for your account by taking the last 20 bytes of the Keccak-256 hash of the public key and adding 0x to the beginning.

The following example shows how to use a signing tool called Clef to generate a new account. Clef is an account management and signing tool that comes bundled with the Ethereum client, Geth. The clef newaccount command creates a new key pair and saves them in an encrypted keystore.

1> clef newaccount --keystore <path>
2
3Please enter a password for the new account to be created:
4> <password>
5
6------------
7INFO [10-28|16:19:09.156] Your new key was generated address=0x5e97870f263700f46aa00d967821199b9bc5a120
8WARN [10-28|16:19:09.306] Please backup your key file path=/home/user/go-ethereum/data/keystore/UTC--2022-10-28T15-19-08.000825927Z--5e97870f263700f46aa00d967821199b9bc5a120
9WARN [10-28|16:19:09.306] Please remember your password!
10Generated account 0x5e97870f263700f46aa00d967821199b9bc5a120
11
Show all

Geth documentation

It is possible to derive new public keys from your private key but you cannot derive a private key from public keys. This means it's vital to keep a private key safe and, as the name suggests, PRIVATE.

You need a private key to sign messages and transactions which output a signature. Others can then take the signature to derive your public key, proving the author of the message. In your application, you can use a javascript library to send transactions to the network.

CONTRACT ACCOUNTS

Contract accounts also have a 42 character hexadecimal address:

Example:

0x06012c8cf97bead5deae237070f9587f8e7a266d

The contract address is usually given when a contract is deployed to the Ethereum Blockchain. The address comes from the creator's address and the number of transactions sent from that address (the “nonce”).

VALIDATOR KEYS

There is also another type of key in Ethereum, introduced when Ethereum switched from proof-of-work to proof-of-stake based consensus. These are 'BLS' keys and they are used to identify validators. These keys can be efficiently aggregated to reduce the bandwidth required for the network to come to consensus. Without this key aggregation the minimum stake for a validator would be much higher.

More on validator keys.

A NOTE ON WALLETS

An account is not a wallet. An account is the keypair for a user-owned Ethereum account. A wallet is an interface or application that lets you interact with your Ethereum account.

A VISUAL DEMO

Watch Austin walk you through hash functions, and key pairs.


Ethereum Account Abstraction proposal ( EIP-2938 )

https://eips.ethereum.org/EIPS/eip-2938

Account abstraction (AA) allows a contract to be the top-level account that pays fees and starts transaction execution.

Transaction validity, as of Muir Glacier, is defined rigidly by the protocol: ECDSA signature, a simple nonce, and account balance. Account abstraction extends the validity conditions of transactions with the execution of arbitrary EVM bytecode (with some limits on what state may be accessed.) To signal validity, we propose a new EVM opcode PAYGAS, which also sets the gas price and gas limit the contract is willing to pay.

We split account abstraction into two tiers: single-tenant AA, which is intended to support wallets or other use cases with few participants, and multi-tenant AA, which is intended to support applications with many participants (eg. tornado.cash, Uniswap).

The existing limitations preclude innovation in a number of important areas, particularly:

  1. Smart contract wallets that use signature verification other than ECDSA (eg. Schnorr, BLS, post-quantum…)
  2. Smart contract wallets that include features such as multisig verification or social recovery, reducing the highly prevalent risk of funds being lost or stolen
  3. Privacy-preserving systems like tornado.cash
  4. Attempts to improve gas efficiency of DeFi protocols by preventing transactions that don’t satisfy high-level conditions (eg. existence of a matching order) from being included on chain
  5. Users being able to pay for transaction fees in a token other than ETH (eg. by converting that token into the ETH needed for fees inside the transaction in real-time)

Most of the above use cases are currently possible using intermediaries, most notably the Gas Station Network and application-specific alternatives. These implementations are (i) technically inefficient, due to the extra 21000 gas to pay for the relayer, (ii) economically inefficient, as relayers need to make a profit on top of the gas fees that they pay.

In an account abstraction setup, the goal is to allow accounts to specify EVM code that can establish more flexible conditions for a transaction’s validity, but with the requirement that this EVM code can be quickly verified, with the same safety properties as the existing setup.


Ethereum Transactions

https://ethereum.org/en/developers/docs/transactions/

Transactions are cryptographically signed instructions from accounts. An account will initiate a transaction to update the state of the Ethereum network. The simplest transaction is transferring ETH from one account to another.

Transactions, which change the state of the EVM, need to be broadcast to the whole network. Any node can broadcast a request for a transaction to be executed on the EVM; after this happens, a validator will execute the transaction and propagate the resulting state change to the rest of the network.

Transactions require a fee and must be included in a validated block. 

But a transaction object needs to be signed using the sender's private key. This proves that the transaction could only have come from the sender and was not sent fraudulently.

An Ethereum client like Geth will handle this signing process.


Code Block
titleethereum transaction
collapsetrue
{
  "id": 2,
  "jsonrpc": "2.0",
  "method": "account_signTransaction",
  "params": [
    {
      "from": "0x1923f626bb8dc025849e00f99c25fe2b2f7fb0db",
      "gas": "0x55555",
      "maxFeePerGas": "0x1234",
      "maxPriorityFeePerGas": "0x1234",
      "input": "0xabcd",
      "nonce": "0x0",
      "to": "0x07a565b7ed7d7a678680a4c162885bedbb695fe0",
      "value": "0x1234"
    }
  ]
}

<<< RESPONSE
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "raw": "0xf88380018203339407a565b7ed7d7a678680a4c162885bedbb695fe080a44401a6e4000000000000000000000000000000000000000000000000000000000000001226a0223a7c9bcf5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20ea02aadee6b34b45bb15bc42d9c09de4a6754e7000908da72d48cc7704971491663",
    "tx": {
      "nonce": "0x0",
      "maxFeePerGas": "0x1234",
      "maxPriorityFeePerGas": "0x1234",
      "gas": "0x55555",
      "to": "0x07a565b7ed7d7a678680a4c162885bedbb695fe0",
      "value": "0x1234",
      "input": "0xabcd",
      "v": "0x26",
      "r": "0x223a7c9bcf5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20e",
      "s": "0x2aadee6b34b45bb15bc42d9c09de4a6754e7000908da72d48cc7704971491663",
      "hash": "0xeba2df809e7a612a0a0d444ccfa5c839624bdc00dd29e3340d46df3870f8a30e"
    }
  }
}

The vast majority of transactions access a contract from an externally-owned account. Most contracts are written in Solidity and interpret their data field in accordance with the application binary interface (ABI).

The first four bytes specify which function to call, using the hash of the function's name and arguments. You can sometimes identify the function from the selector using this database.



DApps Concepts

https://ethereum.org/en/developers/docs/dapps/

...

https://ethereum.org/en/developers/docs/smart-contracts/languages/




https://www.theserverside.com/tip/Introduction-to-Solidity-Build-an-Ethereum-smart-contract



Ethereum and Web3 apps

https://ethereum.org/en/developers/docs/web2-vs-web3/

...

layer2-Vitalik Buterin outlines endgame roadmap for ETH 20.pdf


both optimistic and zero knowledge proof rollups

https://finance.yahoo.com/news/ethereum-no-longer-one-chain-123000149.html

Ethereum is no longer a one-chain ecosystem. In order to achieve scalability, the Ethereum community will need to offer layer 2 technologies capable of handling transactions from billions of users. 2021 proved to be the first step in experimentation with both optimistic and zero knowledge proof rollups, and the two finally began to take significant market share in daily transactions away from Ethereum L1.



Ethereum Smart Contract Development

...

Basic steps to run a smart contract on a blockchain

  1. The distributed ledger should be equipped to record computer programs.
  2. Whenever a user executes a DApp, the execution should happen at every peer/computer holding the ledger copy.
  3. The nodes (network participants holding the blockchain copy) should have an execution environment to execute the DApp.
  4. The system should have a mechanism to uniquely identify a program, its associated data and its executions.
  5. Finally, these changes should be recorded as transactions on the chain.

Smart contract environment

  • Smart contracts ( SC ) run on an emulated computer called the Ethereum Virtual Machine (EVM).
  • Each node on the Ethereum network runs a local copy of the EVM to validate contract execution.
  • At the same time, the Ethereum blockchain records the changing state of this world computer as it processes transactions and smart contracts. 
  • The EVM operates like a global, single-instance computer, running everywhere.
  • Each smart contract is uniquely identified by its 20-byte contract address and has a smart contract program code
  • Each SC is owned and controlled by the logic of its smart contract program code that is recorded on the Ethereum blockchain at the contract account’s creation and executed by the EVM.
    • No one can steal the funds of a smart contract since it does not have a private key to be stolen.
  • Contract funds are accessed only by programming the transfers in the smart contract code, which is publicly auditable.
  • Externally Owned Accounts or EOAs are controlled by users using their private keys.
    • They are often managed by wallet applications external to the Ethereum platform.
  • Smart contract deployment is also a blockchain transaction
  • Smart contracts are written in high-level languages like Solidity


Code Block
titlehello world contract
collapsetrue
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

contract MyContract {
    string message = "Hello Ethereum";

    function setMessage(string memory _message) public {
        message = _message;
    }

    function getMessage() public view returns (string memory) {
        return message;
    }
}

Smart Contract Gas Fees on Ethereum

Ethereum introduces a metering mechanism called gas. As the EVM executes a smart contract, it carefully accounts for every instruction (computation, data access, etc.). Each instruction has a predetermined cost in units of gas. When a transaction triggers the execution of a smart contract, it must include an amount of gas that sets the upper limit of what can be consumed running the smart contract. The EVM will terminate execution if the amount of gas consumed by computation exceeds the gas available in the transaction.

Image Modified


 The Solidity compiler (solc) converts the smart contract to EVM bytecode

The compiler also generates an Application Binary Interface (ABI). ABI serves as an interface between two program modules. It defines how data structures and functions are accessed in machine code.

Deployment after compile

the contract can be deployed using a particular contract deployment transaction. Once the transaction is included in a block, the contract can be referred to by its address. The address of a smart contract is calculated as a hash function of the originating account and account nonce (number of transactions originated from an account).

An Ethereum user who wants to interact with a smart contract can use the contract address and ABI to interact with it anytime.

MyContract is deployed in Ropsten testnet at contract address 0x0dFA0638dd508bFb4E13A06359FAF666677D7F4d. You can check the contract status at the block explorer.

Interact with Ethereum Smart Contracts

...

Connect your test wallet to the testnet

We can interact with an already deployed smart contract by using its contract address and the ABI. For that, we first need to connect to the blockchain network. Wallets are simple applications allowing users to connect with a blockchain network. They act as account managers who manage the user’s keys and transactions. We will be using a MetaMask wallet to connect with the Goerli test network, which got our smart contract. MetaMask installation is already described in our previous blog on HD Wallets. Kindly follow those instructions to install MetaMask.

Connection goes to mainnet so switch to the testnet

...

Interact with the Contract thru an IDE

Remix IDE is an open-source web and desktop application. You can directly access it from your web browser; just go to https://remix.ethereum.org.

Open a new file and copy the ABI from https://goerli.etherscan.io/address/0x44E84A10341BF772906c37fFc30CDbb132eA35f2#code. Save it as filename.abi



Switch to the deploy and run transaction tab from the menu on the left side. Select the environment as Injected Web3 to connect with the MetaMask. Make sure you are logged into MetaMask and connected to the Goerli testnet. Enter the contract address (0x44E84A10341BF772906c37fFc30CDbb132eA35f2) at the designated place and click on At Address as shown in the figure. Remix IDE will ask you for confirmation before loading the contract instance. An instance of the contract will be available under the heading deployed contracts. You can expand it to interact with it.

CALL vs TRANSACTION

Try to invoke the getMessage function by clicking on it. At the console below the editor space, you will get the status of the method call.

...

Click on confirm. MetaMask will use your private key to sign the transaction and send it across the network. Once it gets verified by the network and added to the block, you will get a confirmation from MetaMask (it may take approximately 10–15 seconds). The transaction details can be seen in the Remix IDE console also.

Click on the view on etherscan option to view transaction in etherscan. The transaction input data will be in a default encoded format. Click on decode input data to view it in text format.

Image Modified


Deploy a copy of this contract

Do you wish to deploy the smart contract independently?. It’s simple, just copy the contract source code of the smart contract and save it in a .sol file in Remix IDE. Now go to the solidity compiler tab and compile the smart contract. Make sure you see a tick on the compilation icon.

Image Modified

Next, go to the deploy and run transactions tab. Make sure that your MetaMask is active and connected to the test network.

Image Modified


Select deployment environment as Injected Web3 to connect to MetaMask. Deploy the contract. Confirm the MetaMask transaction notification and wait until your contract deployment transaction is confirmed. Now you can interact with the newly deployed smart contract.


Create Solidity Smart Contracts - Baeldung

...

EVM overview of contract types

From a practical standpoint, the EVM can be thought of as a large, decentralized system containing millions of objects, called accounts, which can maintain an internal database, execute code and talk to each other.

The first type of account is probably the most familiar for the average user who uses the network. Its name is EOA (Externally Owned Account); it is used to transmit value (such as Ether) and is controlled by a private key.

On the other hand, there is another type of account which is the contract. Let's go ahead and see what is this about:



Web3j - run a Java class via API on an Ethereum client

...

https://linuxtut.com/en/7ab984027aa8ff14e4b7/

If you want to use the contract used in solidity with web3j, you need to use Java classes to operate the contract.


Solidity Smart Contract Development Tutorial - Digital Asset Purchase 

Evm-ethereum-notes3   gdoc

Ethereum Optimizations


Optimistic Roll up strategies to combine offline transactions online

https://www.coindesk.com/layer2/2022/02/16/ethereums-rollups-arent-all-built-the-same/

Optimistic rollups do not largely change the trust assumptions of Ethereum, as any user is capable of running a sequencer (Arbitrum full node) that processes transactions and allows users to withdraw funds to mainnet. Sequencers are required to put up a “fidelity bond” on mainnet, thereby creating a financial incentive to be truthful. If another user disputes the sequencer’s transactions, and they are found to be dishonest, the fidelity bond is paid out to the disputer. Financial incentives and multiple sequencers will allow the layer 2s to have strong uptime performance and lean on Ethereum’s security without the concern of interference.

By socializing gas cost across bundled users and only posting calldata to mainnet, Optimistic rollups are able to achieve transaction fees 10-100x cheaper than the corresponding transaction on Ethereum layer 1. These fees will continue to get cheaper as data storage is optimized on mainnet for rollups and sharding, splitting the network in multiple chains to relieve congestion, is eventually implemented.

ZK Rollups

Zero knowledge (zk) rollups bunch together hundreds of off-chain transactions using extensive computation and post them bundled to mainnet in what is known as a “validity proof.” The validity proof is the already computed state of the layer 2 that is sent to mainnet for storage, which contains much less data than the calldata used in Optimistic rollups. Starkware, Polygon Hermez and zkSync are a few of the first implementations of Ethereum based zk rollups creating low cost, application specific layer 2s

Since zk rollups are so computationally intensive and is of limited to a few use cases.


EIP for Stake withdrawals

A new Ethereum Improvement Proposal (EIP) would set the foundation for staked ether withdrawals after the transition to proof-of-stake. BACKGROUND: While the EIP won’t immediately allow validator withdrawals, it sets the stage for the simple upgrade that makes the process possible.

POS consensus



Web3 frameworks for Ethereum

...

Polygon - faster, low cost EVM compatible protocol delivers a POS multi-chain system


https://coinmarketcap.com/currencies/polygon/

...

https://coinmarketcap.com/alexandria/glossary/blockchain-trilemma

decentralization, security and scalability — that developers encounter when building blockchains, forcing them to ultimately sacrifice one "aspect" for as a trade-off to accommodate the other two. 


Polygon performance - 65,000 TPS,  2 second block finalization, $.01 transaction fee -  221016

...

  • Ability to process transactions quickly: By using a consensus mechanism that completes the transaction confirmation process in a single block, Polygon can maintain fast transaction processing speeds. Polygon's average block processing time is 2.1 seconds.8


Polygon uses sidechains

https://coinmarketcap.com/alexandria/glossary/side-chain

...

https://coinmarketcap.com/alexandria/glossary/layer-2

Layer 2 is the name given to a scaling solution that enables high throughput of transactions while fully inheriting the security of the underlying blockchain that it is built on. 


Zero Knowledge Rollups

Ethereum Scaling Tool Polygon Launches its zkEVM Public Testnet

https://finance.yahoo.com/news/ethereum-scaling-tool-polygon-launches-160000399.html

Polygon is a scaling tool aiming to facilitate lower-cost transactions, and uses the Ethereum blockchain as its base protocol. With the introduction of zero-knowledge (ZK) rollup technology, Polygon is hoping to become the chief scalable system for Ethereum.

With the public testnet going live, some of the biggest decentralized finance (DeFi) platforms, including Aave and Uniswap, as well as Web3 social platform Lens, will be among the first protocols to make use of the zkEVM testnet.

https://coinmarketcap.com/alexandria/glossary/zero-knowledge-rollups

ZK Rollups allow blockchains to validate transactions faster while also ensuring that gas fees remain minimal. Zk-rollups manage to perform better than traditional Layer 1 blockchains like Ethereum because they combine on and off-chain processes. 

zk-rollup consists of two Merkle Trees which are both stored on a smart contract, or in other words, on-chain. One tree is dedicated to storing accounts, while the other stores all balances. Any other type of data generated and used by the zk-rollup is stored off-chain.

as less of the blockchain’s capacity is utilized for transaction validation, gas fees decrease


Optimistic Rollups don't require Trusts up front for faster processing but can orphan bad blocks

https://coinmarketcap.com/alexandria/article/optimistic-rollups-for-the-rest-of-us

ORUs support smart contracts with open participation, like Uniswap.

ORUs do not require that users lock up capital upfront.

Unlike channels and Plasma, ORUs are resistant to chain congestion, since fraud is proven at the block level rather than the channel closure or Plasma exit level.

ORU blocks can be posted to Ethereum immediately. Since valid ORU blocks can't be rolled back, they have the same finality guarantees as Ethereum as soon as they're posted to Ethereum.

community has embraced ORUs wholeheartedly as a way to scale Ethereum-style smart contract execution without having to wait for Serenity Phase 2.




https://polygon.technology/

Polygon believes in Web3 for all. Polygon is a decentralised Ethereum scaling platform that enables developers to build scalable user-friendly dApps with low transaction fees without ever sacrificing on security.

Polygon combines the best of Ethereum and sovereign blockchains into a full-fledged multi-chain system.

...

Today, we’re introducing crypto payouts for Connect. With crypto payouts, a select group of creators on Twitter—our first partner—will be able to use cryptocurrency-based rails to receive their earnings from Twitter.

With crypto payouts for Connect, Twitter will make it possible for creators who opt in to have their earnings paid out to a cryptocurrency wallet. Stripe will handle all crypto-related complexity and operations. No code changes are required, and platforms can avoid taking on the challenges of acquiring, storing, or transferring crypto themselves.

Stripe will initially support payouts in USDC, a stablecoin pegged to the US dollar. This will enable many people who wouldn’t otherwise be able to hold dollars to do so. Payouts will take place over the Polygon network, which we chose for its low fees, speed, integration with Ethereum, and broad wallet compatibility (including MetaMask, Coinbase Wallet, and Rainbow). Once creators receive their earnings, they can hold their balance on Polygon, or choose to bridge to Ethereum and exchange it into another currency. We plan to add support for additional rails and payout currencies over time.

wikipedia on polygon

https://en.wikipedia.org/wiki/Polygon

Polygon (formerly MATIC Network) is an Indian blockchain scalability platform. It addresses the challenges faced by Ethereum such as high fees, poor user experience, and low transaction count per second. One of the methods used to address these issues is providing a framework for Proof of Stake transactions.[3] It aims to create a multi-chain blockchain ecosystem compatible with Ethereum.[4] Polygon uses MATIC as its native token.

In April 2022, financial solutions company Stripe chose Polygon for cryptocurrency payments for its “low fees, speed, integration with Ethereum, and compatibility with many wallets”. Twitter was the first beneficiary of the service powered by Polygon


https://www.fool.com/investing/2022/09/15/polygons-latest-announcement-signals-a-rare-buying/?source=eptyholnk0000202&utm_source=yahoo-host&utm_medium=feed&utm_campaign=article

they believe that Ethereum will be the primary blockchain of Web3. But in order for Ethereum to reach the masses cost effectively and Web3 to become mainstream, Polygon will need to be utilized. Co-founder of polygon, Mihailo Bjelic, envisions Polygon eventually becoming "the holy grail of Web3 infrastructure." He believes the ideal Web3 blockchain should possess three primary characteristics: "scalability, security, and Ethereum compatibility" -- something Polygon surely possesses.


Compare Polygon, Solana and Ethereum on performance, cost

...