Blockchain Note – Concepts Interview Questions

1. What is the difference between Wei and Ether (Ethernet) in Ethereum?
A: Wei is the minimum face value of the Ethanol. It is like saying that the minimum face value of the RMB is a cent. The minimum face value of the pound is a penny. The conversion relationship is 1 Ethanol = 10^18Wei.

2. What is the average block interval between Ethereum?
A: The average block interval is 14 seconds. Of course, this is only the theoretical value, you can do it at Etherscan.
(https://etherscan.io/chart/blocktime)
The daily average block interval was found.

3. What is the average block size of Ethereum?
A: The block size is subject to availability and is approximately 2KB. Unlike Bitcoin, which uses the block size to specify the upper limit of the volume of the block, Ethereum uses the gas limit. The fuel limit determines the amount of transaction and storage/bandwidth that is processed in each block, because the execution of functions in transactions and smart contracts is based on the complexity of the instructions, so the fuel limit is used to constrain the area. The block size is feasible.

To figure out how many transactions you can hold in a block, you don’t need to know the price of the fuel clearly, just know how much fuel is used per trade and divide the entire fuel limit by it.

4. What is the node in Ethereum?
A: Essentially, a node is a computer that connects to a blockchain and can handle transactions.

5. What networks are there in Ethereum?
A: There are three types of networks in Ethereum: the Ethereum main chain (the Ethereum we usually use), the Ethereum test network (such as Ropsten and Rinkeby for developers to learn and test) and the Ethereum private chain (also called Ethereum private network, anyone can use the code to deploy their own private chain).

6. What are the methods for interacting with the Ethereum network?
A: You can use e-wallet or DApp.

7. Can you “hide” a transaction in Ethereum?
A: No. All transactions in the Ethereum blockchain are publicly visible.

8. Where is the transaction record of Ethereum stored?
A: In a publicly visible book, this book is often referred to as a blockchain.

9. The Ethereum main chain is already very strong. Why use the Ethereum private chain?
A: There are many reasons, mainly because the data involves privacy, decentralization of the database, access control and testing.

10. How can I view the details of a transaction or a block?
A: You can use a blockchain browser such as http://etherscan.io or live.ether.camp.

11. How do I view the details of a transaction or a block in the private chain?
A: Some open source blockchain browsers meet this need, such as the blockchain browser launched by ether party. (https://github.com/etherparty/explorer)

12. What is the consensus process for the blockchain?
A: Consensus is the process of verifying a transaction in accordance with a specific agreement (such as the Ethereum agreement), packaging the transaction into blocks and joining the blockchain.

13. What is the working principle of the Ethereum mining operation?
A: In principle, the mining operation in Ethereum is almost the same as Bitcoin.
To put it simply, for each block that contains transactions, the miner uses the computer to experiment with the answers to the puzzles repeatedly and very quickly until a miner guesses the puzzle.

More specifically, the miner uses the unique block header metadata (including timestamp and software version) and a nonce value of the current block as input to the hash function. The function will return a fixed length and look like A garbled random number consisting of numbers and letters is called a hash value. The characteristic of a hash function is that different inputs correspond to different hash values, so the miner only needs to change the value of the random number to get a completely different hash value.

If the calculated hash value is less than the current target value (drilling difficulty), the miner dug out a block, he will get some Ethereum rewards, and then by broadcasting the block to the entire network, other nodes can Verify the transaction in the block and add the block to the copy of the blockchain in the region after verification. That is to say, if Miner B calculates a hash value, Miner A will immediately stop the hash value calculation of the current block, add the block excavated by B to the blockchain and start a new round of hash calculation. .

It is difficult for miners to cheat in this competition. In order to get the answer to the puzzle, there is no better way to try one by one, and there is no possibility of forging these calculations. This is why the puzzle method is called “work proof”.
On the other hand, the user does not need to verify that the hash value is correct because each node has been verified.

In general, every 12 to 15 seconds, a miner will dig a new block. If the miner’s time to solve the puzzle begins to appear faster or slower, the algorithm will automatically adjust the difficulty of the problem so that the miner’s puzzle time is stable at around 14 seconds.

Miners have a chance to dig into new blocks to earn Ethereum rewards, and their ability to make money depends on luck and the computing power they put into it.
The workload proof algorithm used by Ethereum is called “ethash”, which is designed to require more memory, which makes it more difficult to mine with expensive ASIC miners, because the appearance of ASIC miners is severely squeezed using other The benefits of equipment miners are such that the only profitable form of mining in Bitcoin is the use of such customized chips. In addition, since Ethereum will gradually transition from workload proof mining to equity proof mining, the purchase of ASIC mining machines may not be a wise choice, as Ethereum will be eliminated once it turns to equity.

14. What are the two most commonly used consensus protocols in the blockchain?
A: Proof-of-Activity (PoA) is constantly emerging in the industry as proof of work (PoW) and proof of interest (PoS).

15. Please briefly describe how the proof of equity works.
A: The proof of equity is the creator of the block that is randomly selected based on the amount and timing of the currency held. It is not a computationally intensive form of mining.

16. What tools are needed to sign a transaction?
A: The user’s private key.

17. After the private key is lost, can the user still recover the Ethereum account?
A: Yes, users can use the 12-word mnemonic to recover.

18. What method can I use to connect to the Ethereum node?
A: IPC-RPC, JSON-RPC and WS-RPC (RPC refers to Remote Procedure Call, remote procedure call).

19. What is the unusually hot Geth in Ethereum?
A: Geth is a command line client of Ethereum.

20. What is the default way to connect to the Geth client?
A: By default, IPC-RPC is used to disable all other RPCs.

21. What APIs (Application Programming Interface) are available in the Geth client?
A: Admin, eth, web3, miner, net, personal, shh, debug, and txpool.

22. Which RPCs can you use to connect to the Geth client over the network?
A: You can connect to the Geth client over the network using JSON-RPC or WS-RPC. IPC-RPC can only be used to connect to the locally deployed Geth client.

23. If you enter the command “–rpc”, which RPC is enabled?
A: JSON-RPC.

24. Which RPC APIs are enabled by default?
A: eth (Ethernet), web3 and net (network).

25. How do I enable admin api for JSON-RPC?
A: Enter the command “–rpcapi”.

26. What is the function of the command “–datadir”?
A: It specifies the storage location of the blockchain.

27. What is Geth’s “fast” synchronization, and why is it faster?
A: “Fast” sync only downloads the block where the receipt transaction is located, and pulls the entire recent state database instead of downloading the entire blockchain data and replaying all the transactions that occurred, just like normal sync.

28. What is the function of the command “–testnet”?
A: It connects the client to the Ethereum Ropsten test network.

29. Starting the Geth client will print a lot of output information on the screen. What if you don’t want to be disturbed by these complicated information?
A: Use the “–verbosity” command to lower the value of the output information complexity (default is 3).

30. How to connect two Geth clients using IPC-RPC?
A: First start a Geth client, copy its pipe location, then use the same data file storage directory (data-dir) to start another Geth client and use the “–attach” command to pass the copied pipe location.

31. How do I load a custom javascript file into the Geth console?
A: Enter the path of the “–preload” command and file.

32. Where is the account stored in the Geth client?
A: Stored in the key store directory.

33. How to initiate a transaction using a given account?
A: First you need to enter the account address or index in the “–unlock” command to unlock the account. Then you need to specify a password file for this account using the “–password” command.

34. We just talked about the contents of the index. What is the index of the account?
A: It depends on the order in which you add your account.

35. Can the Geth client be used for mining?
A: Yes, enter the “–mine” command.

36. What is the “etherbase” in the mining options?
A: This is the account address that accepts the mining award. The index of this account is 0.

37. What is ABI?
A: Simply put, “ABI” is a low-level “API”.
The ABI (Application Binary Interface) application binary interface is essentially the way you call a function in a smart contract and get its return value.
The ABI defines how to call functions in a smart contract and which binary format should be used to pass information from one program component to the next.
Ethereum smart contracts are deployed in byte code form on the Ethereum blockchain, and there may be multiple functions in a smart contract. So, with ABI, you can specify which function in the smart contract to call to ensure that the return value of the function is the format you expect.

ABI is an abstraction that is not part of the Ethereum core protocol. Anyone can define a proprietary ABI for their smart contracts, and any caller of these smart contracts must follow the ABI’s rules in order to get meaningful call results. However, for all developers, using Solidity, Serpent and web3.js is much simpler, and these are also in line with ABI regulations.

38. What is a smart contract?
A: In essence, smart contracts are computer code written in multiple languages. Smart contracts exist on the blockchain network, and they perform related operations according to their own embedded rules, which can be seen as contracts between participants.

39. What are the usage scenarios for smart contracts?
A: For a simple commodity trading scenario, the buyer deploys a smart contract in Ethereum and deposits funds into it. The seller sees the deposited funds and sends the goods. After the buyer receives the goods, the buyer pays the goods through the smart contract. The smart contract here can be seen as a decentralized Alipay that protects Taobao transactions.

40. What is MetaMask?
A: Metamask is a plug-in type of Ethereum wallet that helps users interact with the Ethereum network in the browser.

41. What node does Metamask use?
A: It uses http://infura.io.

42. Compared with the traditional Ethereum wallet, what features are not supported by Metamask?
A: It does not support mining and deployment of smart contracts.

43. Is the execution of smart contracts free?
A: No, smart contracts can only be invoked by executing a trade, and the transaction requires fuel costs.

44. Is the status of the smart contract free?
A: Yes, the query status does not need to execute a transaction.

45. Who will execute the smart contract?
A: Miners.

46. ​​Why does it take money to call a function in a smart contract?
A: In addition to some functions that do not change the state of the smart contract, there is no logic other than the return value. Calling the function in the smart contract costs money.

In this cost, in addition to transferring the call to the Ethereum into the smart contract, calling the function that changes the state of the smart contract requires fuel to execute.

47. Why is it necessary to introduce fuel costs in Ethereum?
A: Because the miners use their own computers (mineral machines) to execute the smart contract code, if the miners can recover the cost of purchasing the machine and earn profits to ensure the safety of the entire system, the Ethereum design allows the miners to execute the caller’s request. Code to earn fuel costs to maintain a healthy ecology.

48. Can the fuel price determine when the transaction is processed?
A: Yes, not all. In general, the higher the fuel price you pay, the more likely the deal will be added to the blockchain. Still, fuel prices do not guarantee that transactions are processed faster.

49. What is the amount of fuel used in the transaction?
A: The amount of fuel used depends on the amount of storage, the type and quantity of instructions (opcodes). The operating code of each Ethereine virtual machine clearly defines the amount of fuel required.

50. How to calculate the transaction fee?
A: Transaction fee = quantity of fuel used * fuel price (fuel price specified by the trader).

51. If the cost of executing a smart contract is less than the fuel cost paid by the trader, will he get a refund?
A: Yes.

52. What happens if the cost of executing a smart contract exceeds the fuel cost paid by the trader?
A: Users will not receive a refund, and will stop once all fuel is exhausted, and the status of the smart contract will not change.

53. Who will pay for the call to the smart contract?
A: The user who invoked the smart contract.

54. Where does the node run the code for the smart contract?
A: The node runs the code for the smart contract in the Ethereum Virtual Machine (EVM). The Ethereum virtual machine specification is part of the Ethereum agreement. The Ethereum virtual machine is just a process that the node runs.

55. What tools does the Ethereum virtual machine need to run smart contracts?
A: It requires the byte-code of the smart contract, which is compiled and compiled by a high-level language such as Solidity.

56. What are the parts of the Ethereum virtual machine?
A: Memory area, stack and execution engine.

57. What is Remix?
A: Remix is ​​an online tool for developing, testing and deploying smart contracts. It’s great for quickly building and testing lightweight smart contracts, but not for complex smart contracts.

58. In Remix, which nodes can you connect to?
A: You can use the Metamask wallet to connect to the public node, use the Geth wallet to connect to the local node and use the Javascript virtual machine to connect to the in-memory simulated node.

59. What is a DApp, how is it different from a regular app?
A: Applications typically include a client that interacts with certain centralized resources (owned by the organization) and typically has an intermediate layer that is connected to the centralized data layer. If the data in the centralized data layer is lost, it cannot be (easily) restored.

DApp represents a decentralized application. DApps interact with blockchain networks through smart contracts, and the data they use resides in instances of smart contracts, and decentralized data is more secure than centralized data.

60. Solidity is a statically typed language (type checking is done before running, such as the compile phase) or dynamic type language (type checking is done at runtime)?
A: Solidity is a statically typed language, which means that the type is known at compile time.

61. What structure in Solidity corresponds to a class in Java?
A: Smart contract.

62. What is an example of a smart contract?
A: An example of a smart contract is a smart contract deployed on the blockchain.

63. What are the differences between Java and Solidity.
A: Compared to Java, Solidity supports multiple inheritance, but does not support method overloading.

64. What is the first parameter that needs to be specified in the Solidity file?
A: The first parameter is the version of the Solidity compiler, which needs to be specified as ^ 0.4.8. Don’t underestimate this step because it avoids incompatibility errors introduced when compiling with other versions of the compiler.

65. What does a smart contract contain?
A: Smart contracts consist primarily of storage variables, functions, and events.

66. What types of functions are there in smart contracts?
A: There are constructors, fallback functions, constant functions, and functions that modify the state of smart contracts.

67. What happens if I put multiple smart contract definitions into a single Solidity file?
A: It is entirely feasible to put multiple smart contract definitions into a single Solidity file.

68. How can two smart contracts interact?
A: A smart contract can call, create, and inherit another smart contract.

69. What happens when you try to deploy a file with multiple smart contracts?
A: The compiler will only deploy the last smart contract in the file, which means that all other smart contracts are ignored.

70. If I have a huge project, do I need to keep all relevant smart contracts in one file?
A: No, you can use the import statement to import the file as follows:
Import “./MyOtherContracts.sol”;

71. Can I only import local files?
A: No, you can also use HTTP to import files (even files on Github) as follows:
Import “http://github.com/<owner>/<repo>/<path to the file>”

72. What are the parts of the Ethereum virtual machine’s memory?
A: Storage, Memory, and Calldata.

73. Please explain the storage.
A: You can think of storage as a database. Each smart contract manages its own storage variables, resulting in a key-value pair database (256-bit keys and values). The only difference between storage and a normal database is that it costs more to read and write because of the cost of fuel.

74. Please explain the memory.
A: Memory is a temporary storage. When the function call is executed, the data in the memory will be released. You can allocate a variety of complex data types, such as arrays and structures, in memory.

75. Please explain Calldata.
A: Calldata can be understood as a function call stack (Callstack). It is temporary and unmodifiable. It stores the execution data of the Ethereum virtual machine.

76. What variables are stored in the memory area and memory area respectively?
A: State variables and local variables (usually local variables are references to state variables) are in the store, and the parameters of the function are in the memory area.

77. Read the following code, explain which part of the code corresponds to which memory area:

contract MyContract {
  // part 1
  Uint count;
  Uint[] totalPoints;

  function localVars(){
    // part 2
    Uint[] localArr;
    // part 3
    Uint[] memory memoryArr;
    // part 4
    Uint[] pointer = totalPoints;
  }
}

A: Part 1 – Storage.
Part 2 – Storage (array size points to the position of the counter)
Part 3 – Memory.
Part 4 – References to storage.

78. Can I define a function like this:
Function doSomething(uint[] storage args) internal returns(uint[] storage data) {…}
A: Yes, you can force the function’s argument to be a storage type. In this case, the compiler will complain if you don’t pass in a stored reference to the function.

79. What is the difference between EVM calls and non-EVM calls?
A: An EVM call is a function call in a smart contract that triggers function execution and requires fuel.
Non-EVM calls read publicly visible data and do not require fuel.

80. How do I set the Ethereum balance limit for smart contracts? What happens if I send excess Ethereum to a smart contract with a balance limit? answer:

Pragma solidity ^0.4.19;

contract yourContract{

  Uint256 public balanceLimit = 999;

  function () payable{
   If (this.balance + msg.value > balanceLimit) {
     Throw; / / will roll back after the excess.
   }
  }
}

81. How to set the value of msg.val in the smart contract account?
A: msg.val => msg.value = the number of weis sent with the message.

82. What is DApp?
A: A Decentralized Application (DApp) is an application that runs on a peer-to-peer network rather than a single computer. Decentralized applications have existed since the advent of peer-to-peer networks, a software tool designed to exist on the Internet in a way that is not controlled by any entity.

Decentralized applications do not necessarily need to run on a blockchain network. BitTorrent (decentralized download software), Popcorn Time (decentralized video software), BitMessage (decentralized communication protocol), Tor (onion routing) are traditional decentralized applications running on peer-to-peer networks, both of which Not running on the blockchain (blockchain is a special peer-to-peer network).
Contrary to a simple smart contract, in the classic usage scenario of Bitcoin, where user A sends money to user B, the participant in the decentralized application can be anyone in the market.

83. What is the difference between DApp and smart contracts?
A: The decentralized application is a blockchain-based website where smart contracts allow it to connect to the blockchain. To put it bluntly, in order to better understand decentralized applications and smart contracts, let’s first understand how traditional websites work.

Traditional web (web) applications use HTML, CSS, and Javascript to render the page on the front end. On the back end, it needs to use the API to get some detailed information from the database, such as the user’s username and avatar. When you enter the web version of Sina Weibo, the page will call the API to get your personal data and display it on the page. In other words, the traditional website works in the following way: Front End → API → Database.

A decentralized application is similar to a traditional web application. It uses the exact same technology to render the page on the front end. One key difference is that decentralized applications do not use APIs to connect to the database, but instead use smart contracts to connect to the blockchain. So, the way a website based on a decentralized application works is: Front End → Smart Contract → Blockchain.

In traditional centralized applications, the back-end code runs on a centralized server. In contrast to decentralized applications, its back-end code runs on a decentralized peer-to-peer network. Decentralized applications include the entire package from the back end to the front end, and smart contracts are just part of the decentralized application.

In other words, the DApp includes:
1) Front end (the page you can see)
2) Backend (application backend logic)

On the other hand, smart contracts only contain backends, usually just a small part of the entire DApp. This means that if you want to create a decentralized application on a smart contract system, you must combine multiple smart contracts and rely on third-party systems as front ends.

84. What tools are used by the front end to connect to the back end of the smart contract?
A: The Web3 API library.

85. Please list a few DApps you know.
A: The Golem project aims to create the world’s first global market for idle computer computing; Augur (word meaning: omen), the Augur project aims to combine predictive and decentralized networks to create A predictive tool to gain potential benefits; Aragon Network, which is designed to serve as a user-friendly digital management organization.

86. What tools do you need to interact with DApp’s smart contracts?
A: ABI and bytecode for smart contracts are required.

87. What is the role of ABI?
A: ABI is a description of the public interface of smart contracts. DApp uses this public interface to invoke smart contracts.

88. What is the role of bytecode?
A: The Ethereum virtual machine on each node requires the smart contract bytecode to run the smart contract.

89. Why use the BigNumber library?
A: Because Javascript can’t handle large numbers correctly.

90. Why should I always check if the web3 provider (provider) is set at the beginning of the DApp code?
A: Because if not, Metamask will overwrite it with its own web3 provider.

91. Why use the 1.x version of web3 js instead of the 0.2x.x version?
A: Mainly because the 1.x version of the asynchronous call uses the promise object (committed to execute in the future, more reasonable and more powerful than the callback object) instead of the callback object, the promise object is also the first choice in javascript.

92. How do I list all accounts in the web3 1.x version?
A: Use the command: “web3.eth.getAccounts”

93. What is the difference between “.call” and “.send”?
A: “.send” initiates a transaction and generates a fee, while “.call” only queries the status of the smart contract without incurring a fee.

94. Is it possible to send an Ethercoin with such a command “.send({value:1})”?
A: No, actually you only sent 1wei (1 Ether = 10^18Wei). The unit in the transaction is wei, not Ethereum.

95.: Does that mean that in order to send an Ethereum, I need to set the value to 10^18?
A: No, it is too much trouble. You can use the util method, ie:
web3.utils.toWei(1,’ether’).

96.: What do I need to specify when calling “.send()”?
A: You must specify the sender address “from”. Everything else is optional.

97: Is the function that sends Ethereum to a specific address only
web3.eth.sendTransaction() one?
A: No, you can also call functions in smart contracts.

98. What is the solution to the scalability problem of Ethereum?
A: The idea to solve the scalability problem is to use the chain trading mechanism. Specific solutions are state channels and plasma.

99.Name the two types of records that are present in the blockchain database?
These records are block records and transactional records. Both these records can easily be accessed, and the best thing is, it is possible to integrate them with each other without following the complex algorithms.
Blockchain is a distributed database. How does it differ from traditional databases?
Properties
Blockchain
Traditional Database
Operations
Only Insert Operations
Can perform C.R.U.D. operations
Replication
Full Replication of block on every peer
Master Slave
Multi-Master
Consensus
Majority of peers agree on the outcome of transactions
Distributed Transactions
(2 phase commit)
Invariants
Anybody can validate transactions across the network
Integrity Constraints
100. What are the properties of Blockchain?
There are four key features of blockchain:
  • Decentralized Systems
  • Distributed ledger
  • Safer & Secure Ecosystem
  • Minting
101.What are Block Identifiers?
In Blockchain, blocks can be identified by the block header hash and the block height.
102. What are Merkle trees? How important are Merkle trees in Blockchains?
Merkle Tree also known as ‘hash tree’ is a data structure in cryptography in which each leaf node is a hash of a block of data, and each non-leaf node is a hash of its child nodes.
31C21472-8B12-483D-B8D9-025FA6913E35
The benefit of using the Merkle Tree in blockchain is that instead of downloading every transaction and every block, a “light client” can only download the chain of block headers.
Also, if someone needs to verify the existence of a specific transaction in a block, then he doesn’t have to download the entire block. Downloading a set of a branch of this tree which contains this transaction is enough. We check the hashes which are just going up the branch (relevant to my transaction). If these hashes check out good, then we know that this particular transaction exist in this block.
103. Can You explain the components of Blockchain Ecosystem?
Following are the components of blockchain Ecosystem:
2BCE8C19-B2B4-4264-9A83-6B0A57EDC874
104. What is Double Spending? Is it possible to double spend in a Blockchain system?
It’s a condition when one digital token is spent multiple times because the token generally consists of a digital file that can easily be cloned. It simply leads to inflation and organizations must bear a huge loss. One of the primary aims of Blockchain technology is to eliminate this approach up to the possible extent.
Blockchain prevents double spending by confirming a transaction by multiple parties before the actual transaction is written to the ledger. It’s no exaggeration to say that the entirety of bitcoin’s system of Blockchain, mining, proof of work, difficulty etc, exist to produce this history of transactions that is computationally impractical to modify.
105. In blockchain, blocks are linked ________?
Backward to the previous block[Ans]
Forward to next block
Not linked with each other
106. Hash identifying each block in the Blockchain is generated using which of the following cryptographic algorithm?
SHA128
SHA256[Ans]
107. Blockchain forks can result in which of the following?
Multiple parent blocks
Multiple children blocks[Ans]
108. A block in the blockchain can never have more than one parent block?
True[Ans]
False
109. Can you explain what are off-chain transactions?
An off-chain transaction is the movement of value outside of the blockchain. While an on-chain transaction – usually referred to as simply ‘a transaction’ – modifies the blockchain and depends on the blockchain to determine its validity an off-chain transaction relies on other methods to record and validate the transaction.
110. What is 51% attack?
51% Attack refers to a situation where a group of miners who hold more than 50% of the Network Hash Rate could manipulate with the New transactions (Stopping the transactions to proceed or gaining conformations) or able to reverse the transactions that were recently confirmed and kind of doing Double spend. It is Highly unlikely to be able to do that today but it is possible.

Reference

  1. https://www.edureka.co/blog/interview-questions/blockchain-interview-questions/
  2. https://zhuanlan.zhihu.com/p/47771150
  3. https://medium.com/coinmonks/blockchain-interview-questions-the-collection-38de299ce44d
  4. https://zhuanlan.zhihu.com/p/48538829

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s