Solidity Flashcards

1
Q

Is Solidity statically or dynamically typed?

A

It is statically typed, which means that types are known at compilation.

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

What is the equivalent to the Java “Class” in Solidity?

A

It’s the Contract.

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

What is an instance of a contract?

A

An instance of a contract is the deployed contract on the blockchain.

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

Give me a couple of differences between Java and Solidity.

A

Solidity supports multiple inheritance but doesn’t support overloading

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

What is the very first thing you must specify in a Solidity file?

A

The version of Solidity compiler, which is specified as ^0.8.8. It is necessary because it prevents incompatibility errors which can be introduced when compiling with another version.

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

What does a contract consist of?

A

It consists mainly of storage variables, functions and events.

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

What types of functions are there?

A

There is a constructor, fallback function, constant functions and functions that modify the contract state.

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

What error will I get if I put multiple contract definitions into a single Solidity file?

A

It is perfectly fine to put multiple contract definitions into a single Solidity file.

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

What are some ways in which two contracts can interact?

A

A contract can invoke, create and inherit from another contract(s).

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

What happens when you try to deploy a file with multiple contracts?

A

The compiler only deploys the last contract in that file and all other contracts are ignored.

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

What if I have a huge project, do I need to keep all my related contracts into a single file?

A

You can use import statement to import a file, import “./MyOtherContracts.sol”

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

Can I only import local files?

A

You can also import files using HTTP (even from Github), import “http://github.com/<owner>/<repo>/<path>"</path></repo></owner>

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

What parts is the memory of an EVM divided into?

A

It is divided into Storage, Memory and Calldata

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

Explain Storage

A

Think of it as a database. Each contract manages its own Storage variables. It is a key-value datastore (256 bit key & value). The read and write are more costly in terms of gas used per execution.

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

Explain Memory

A

It is a temporary storage. The data is lost once the execution terminates. You can allocate complext datatypes like arrays and structs.

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

Explain Calldata

A

It can be thought of as the callstack. It is temporary, non-modifiable, and it stores EVM execution data.

17
Q

What variables are stored in the Storage and Memory areas respectively?

A

State variables and local variables (wich are references to the state variables) are stored in Storage. Function arguments are located in Memory area.