Solidity Flashcards
Is Solidity statically or dynamically typed?
It is statically typed, which means that types are known at compilation.
What is the equivalent to the Java “Class” in Solidity?
It’s the Contract.
What is an instance of a contract?
An instance of a contract is the deployed contract on the blockchain.
Give me a couple of differences between Java and Solidity.
Solidity supports multiple inheritance but doesn’t support overloading
What is the very first thing you must specify in a Solidity file?
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.
What does a contract consist of?
It consists mainly of storage variables, functions and events.
What types of functions are there?
There is a constructor, fallback function, constant functions and functions that modify the contract state.
What error will I get if I put multiple contract definitions into a single Solidity file?
It is perfectly fine to put multiple contract definitions into a single Solidity file.
What are some ways in which two contracts can interact?
A contract can invoke, create and inherit from another contract(s).
What happens when you try to deploy a file with multiple contracts?
The compiler only deploys the last contract in that file and all other contracts are ignored.
What if I have a huge project, do I need to keep all my related contracts into a single file?
You can use import statement to import a file, import “./MyOtherContracts.sol”
Can I only import local files?
You can also import files using HTTP (even from Github), import “http://github.com/<owner>/<repo>/<path>"</path></repo></owner>
What parts is the memory of an EVM divided into?
It is divided into Storage, Memory and Calldata
Explain Storage
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.
Explain Memory
It is a temporary storage. The data is lost once the execution terminates. You can allocate complext datatypes like arrays and structs.