Smart Contract Flashcards

1
Q

Smart Contract

A

A smart contract is a piece of code that facilitates, verifies, or enforces the negotiation or execution of a digital contract.
For us to reach consensus, a trusted entity must run this code.
After all, we need to trust that a digital contract is enforced correctly.
Like a traditional contract, it carries a set of conditions that must be fulfilled, or terms that must be executed on.
The difference is that the execution and enforcement is done through carefully designed algorithms, not through law.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Ethereum

A

Ethereum is a decentralized platform designed to run smart contracts. it’s trustless, immutable, uncensorable, pseudonymous, has no central point of failure, and aims for a one-cpu-one-vote policy (Proof of work consensus). One of the most notable features is that it supports a complete scripting language (language for executing transaction in order, with a script)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Diference between Bitcoin and Ethereum

A

Bitcoin is the “gold standard” of blockchains.
It’s been around for the longest, and its protocol has successfully supported an enormous number of transactions over the past years.
It’s intended purpose is solely to allow the transaction of bitcoins, its native asset.
On the other hand, Ethereum is a smart contract blockchain platform, a distributed world computer.
It’s native asset ether exists to fund computation and to align incentives.
Its primary purpose is not to act as a medium of exchanging value.
Bitcoin is simple and robust.
It’s a global payment system.

Ethereum has a much larger vision, and therefore supports many more features, for example, a much more powerful scripting language.

Bitcoin has a stack based primitive scripting language which is not turing complete, meaning that the applications we can make on Bitcoin are pretty limited. Ethereum on the other hand has a Turing-complete scripting language – one of the motivating
factors for Ethereum’s creation in the first place.
So, a wider variety of applications can be made on Ethereum than on Bitcoin, making it
more developer friendly. Another key difference is that Bitcoin is UTXO-based, whereas Ethereum is account based.

The Proof-of-Work algorithms, in Ethereum, block creation time is 15 seconds long, whereas in Bitcoin, it’s 10 minutes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Account Types in Ethereum

A

In Ethereum, there are two types of accounts: externally owned accounts and contract accounts.

Externally owned accounts are, as their name implies, owned by some external entity – outside
of the Ethereum network. This could be a person, group of people, a corporation, or something else.
Externally owned accounts contain an address that they use to let people send them ether, and also a balance of ether. This type of account can send transactions to transfer ether or to trigger contract code, which lives in contract accounts.

Contract accounts are owned by smart contracts.
They contain an address, associated contract code, and also persistent storage.
Their code is executed when externally owned accounts or other contract accounts make transactions
to trigger their code’s function calls.
Smart contracts in Ethereum are like autonomous agents that live inside of the Ethereum network,
whereas regular users controlling externally owned accounts are not.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Smart Contrat Purposes

A

Ethereum smart contracts generally serve four main purposes.
They can be used to store and maintain data.
The data representing something useful to users or other contracts.
For example, there could be a smart contract defining a new token currency, or perhaps
a certain organization’s membership, which you have to pay a certain amount to obtain.
Smart contracts can also be used to manage a contract or relationship between untrusting
users.
This is perhaps the most easily understood use of smart contracts, as it’s just running
a regular contract but on the distributed Ethereum network.
For example, you could have smart contracts that manage financial contracts, escrow, or
insurance.
Smart contracts can also provide additional functionality to other contracts.
You can write contracts that call other contracts, perhaps using them as a software library,
leveraging the functionality of an existing contract.
And finally, smart contracts can be used for complex authentication use cases.
For example, you can define m of n multisignature, which is also something we looked at when
we studied Bitcoin.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Ethereum Virtual Machine

A

Ethereum smart contracts are generally written in high level programming languages.
The most popular is Solidity, which kind of looks like a mix between C++ and JavaScript.
There’s also Vyper, which is a newer language that’s currently under development.
Smart contracts written in these high level programming languages have to be compiled
down to Ethereum Virtual Machine code, abbreviated as EVM code.
So we go from a higher level, human readable language, and compile that down into EVM code,
which is lower level, simpler language – much easier for a machine to understand and execute.
After the code is compiled to EVM code, every node in the Ethereum network executes it.
And all nodes execute the code the same way, so long as they have an up-to-date version
of the EVM software.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Gas

A

Gas is what fuels the execution of a given contract.
Every EVM op-code requires gas in order to execute – thereby preventing the aforementioned
infinite loop denial of service attack.
Every transaction specifies two parameters, “startgas”, or the maximum quantity of
gas the transaction is willing to consume, and the “gasprice”, or the fee in ether
the contract is willing to pay per unit gas.
At the start of a transaction, “startgas * gasprice”, which represents the amount
of ether paid for a computation, is subtracted from the sender’s account.
The sender being the one who invokes the contract by sending a transaction.
If the contract successfully executes, then the remaining gas is refunded to the sender.
On the other hand, if the contract execution runs out of gas before it finishes, then the
execution reverts.
However, the amount in ether that was consumed is not refunded.
The idea here is that although the contract execution gets reverted, someone on the network
had to put in the computational power to execute the EVM code, and once the gas is spent up,
it’s proof that someone executed the program, so it isn’t refunded.
So this gives us two end states: either a program terminates or runs out of gas.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Solidity

A

It’s a popular contract oriented, high level EVM language for implementing smart contracts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Proof of existence

A

It’s a use case of Ethereum in which we register a document, mark, etc in the blockchain to proof that we created that document in a specific moment in the past.

We store a hash of our document onto the blockchain.
By doing so, we can prove to everyone at any later date that we were the ones who included that hash on the blockchain, and that our information has not been changed.
By doing so, we have now “proved the existence” of some piece of information at some point in time.
With Proof-of-Existence, we leverage both the public auditability and immutability of the blockchain.
With a blockchain, we can cryptographically prove commitment to some particular value.
This is nothing more than a record-keeping use case, and there are several which fall under this category.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly