Smart Contracts and Solidity Flashcards
So what is a smart contract?
It is computer code written in multiple languages. Smart contracts live on the network. They enforce rules and preform actions, negotiated by participants in those contracts.
What languages can smart contracts be written in?
Solidity is the most commonly used
What is Metamask?
Metamask is a tool which helps you to easily interact with the Ethereum networks in your browser
What node does Metamask use?
It uses infura.io
What does Metamask NOT support?
Mining and contract deployment.
Is execution of contracts free?
No, invoking contract methods is a transaction.
Is accessing a Smart Contract state free?
Yes, querying state is not a transaction.
Who executes the contracts?
Miners.
Why does it cost money to invoke a method on a Smart Contract?
Some methods, which do not modify the state of the contract and have no logic other than returning a value, are free. Apart from sending ether as a payment, invoking methods that make change the state cost money also because they require gas for execution.
Why is there gas, more precisely?
Since miners execute contract code on their machines, they must cover their costs from executing the code requested by a caller.
What does the gas usage in a transaction depend on?
It depends on amount of storage, and type and number of instructions (opt codes). Each EVM opt code has a fixed amount of gas.
And how is transaction fee calculated?
Gas used * gas price (specified by the caller)
If an execution of a Smart Contract costs less than the specified gas, does the user get a refund?
Yes
What happens if the execution of a Smart Contract costs more than the specified gas?
The user doesn’t get a refund and also the execution halts as soon as all the gas is used up and no changes are made to the contract.
What do nodes run Smart Contracts code on?
EVM - Ethereum Virtual Machine. EVM follows the EVM specification, which is part of the Ethereum protocol. EVM is simply a process on the node.