78 Ethereum Blockchain Developer Interview Questions & Answers
đ Get your FREE chapter of the Blockchain Developers HandbookâŠ
This guide takes 19 minutes 57 seconds to read.
1. Which Is The Right Order Of Denominations?
Szabo, Mether, Wei, Kwei.
Wei, Finney, Ether, Tether.
Wei, Finney, Szabo, Ether.
2. A Transaction Contains the Nonce Field. Why?
To count how many Ether were sent.
To avoid reply attacks.
To have an additional checksum for transaction values.
3. What Is The Nonce-Field In A Transaction For?
To protect against replay attacks.
To have an additional checksum for transactions.
To sum up all ethers sent from that address.
4. Select Which Statement Is True About The EVM.
While the EVM is sandboxed it isnât as powerful as the Bitcoin network, because itâs not turing complete.
The EVM canât access hardware layers or anything outside a blockchain node, because itâs sandboxed.
The EVM is extremely powerful, turing complete and perfect for doing computational intensive things, because of the direct access to the graphics card.
5. Dapps AreâŠ
Great. Because they cut the middle man, run on a trusted platform, and apply logic to the blockchain where economic assets are already running thus allowing peer to peer trade.
An amazing way to create new applications. Those applications run entirely separated from other applications on the platform, and allow for logical interactions. To add an additional layer of trust they canât access any funds.
Are a new way of applying logical operations for banks and financial institutions. This way they can reduce the staff while operating at increased security.
6. To Get The Most Out Of The Blockchain It Is BestâŠ
To use it for the whole business logic. Itâs best to have everything in once place.
To use it only for those things which need the benefits of the blockchain
7. What Does It Mean If Mean A Hashing Algorithm Is Deterministic?
Given the same input it always produces the same output.
Given a long input it uses equally distributed data to produce the output.
Given the output it shouldnât be possible to re-generate the input.
8. Whatâs The Correct Scientific Notation?
1 Ether = 10Âčâž wei, 10âč Gwei, 10Âł Finney.
1 Ether = 10Âčâč wei, 10ÂčÂł Gwei, 10Âł Finney.
1 Ether = 10Âčâ¶ wei, 10ÂčÂł Gwei, 10Âł Finney.
1 Ether = 10Âčâž wei, 10â¶ Gwei, 10â¶ Finney.
9. What Are Private Keys For?
To protect the public keys by being cryptographically significant.
To sign transactions, and to derive an address from.
To generate an address which can sign transactions.
10. Public Keys vs. Private Keys, Select Which Is True:
The public key is for signing transactions, the private key must be given out to verify the signature.
The private key signs transactions, the public key can verify the signature.
The private key is to generate a public key. The public key can sign transactions the address is here to verify the transactions.
11. Proof of Work (PoW) vs. Proof of Stake (PoS)âŠ
PoW is computationally intensive which requires lots of energy. On the other hand miners earn straightforward a reward for mining a block, and incorporating transactions.
PoW is better than PoS, because with PoS we increase the amount of energy spent on the network.
PoS is mining with specialised hardware that has to be purchased with a stack of Ether in the network. Hence the name âProof of Stakeâ, which derives from stack.
12. Externally Owned AccountsâŠ
Can be destroyed using the selfdestruct keyword. This way all remaining ether will be sent to the receiver address, regardless of if they have a fallback function.
Are bound to a private key which is necessary to sign transactions outgoing from that account.
Are logical opcodes running on ethereums blockchain similar to smart contracts.
13. What Are Ethereum Nodes?
Programs implementing the Ethereum protocol to talk to each other , and JSON-RPC interfaces to talk to the outside world.
A Java-Script library to compile and run Solidity code.
A framework for deploying, and running smart contract in a decentralised way.
14. To Communicate With An Ethereum Node Via JavaScriptâŠ
The library you use must make use of the JSON-RPC interface of an Ethereum node.
Must implement the Ethereum protocol to connect to other Ethereum nodes.
Must use Web3.js, which is closed source to communicate to other nodes.
15. Itâs Possible To Access The Blockchain Via An Ethereum NodeâŠ
Only via JavaScript because there is the proprietary Web3.js library.
With any language, as long as it adheres to the JSON-RPC standard.
16. A Private Network IsâŠ
A side channel to the Ethereum main net, which costs less gas to run smart contracts.
A network running only in a private area, where people cannot join freely and openly.
An exact clone of the Rinkeby Test-Network, which can be started as a virtual machine in the Azure Cloud.
17. For Rapid Development Cycles Itâs GoodâŠ
To deploy to the main-network as quickly as possible.
To use in-memory blockchain simulations, because mining works instantaneously.
To use a private network at all times, because itâs the closest to the real network.
18. Go-Ethereum vs. GanacheâŠ
Both are the same, just implemented in a different language.
With Go-Ethereum you get a real blockchain node where you can create your own local private network, connect to Test-Networks or the Main-Net, while with Ganache you get an in-memory blockchain simulation.
With Ganache you get a real blockchain node, where you can connect to the Test-Neworks Rinkeby and Ropsten.
19. Topic: Block TimestampâŠ
Because the timestamp is based on the timezone of the miner, it changes the difficulty continuously to reflect network latency.
The timestamp can be influenced by a miner to a certain degree, but itâs always independent from the time-zone.
The timestamp canât be influenced by a miner, and is generally considered safe to be used for randomness on the blockchain.
20. Block DifficultyâŠ
Is determined by the Ethereum committee fortnightly to reflect the average amount of transaction, and canât be influenced by the network.
Increases when the time between mined blocks is below 10 seconds, while it decreases when the time is above 20 seconds.
Increases when the time between mined blocks is below 20 seconds, while it decreases when the tie is above 60 seconds.
21. Ethereum NodesâŠ
Must implement the Ethereum protocol, and external access can only be done via the proprietary Ethereum libraries like Web3.js.
Must implement the Ethereum protocol, and a JSON-RPC to talk with clients.
Must implement Web3.js to interact with websites.
22. When A New Block Is MinedâŠ
A list of transactions, and uncles are incorporated in the block. All gas that is used during those transactions are added to the miners balance, and the block reward is added to the miner. Then the same transactions are run again by every participating node in the network to achieve consensus.
A list of transactions is incorporated in that block. Gas used during the execution is attached to the executing contracts, while the block reward is automatically spread across the mining pool to ensure a fair spread. Consensus is reached by a special form of hash code.
23. Smart Contracts Can Be Written InâŠ
Java, C++, Solidity and JavaScript. The Ethereum blockchain is completely language agnostic, and cross compilers for every major language exist.
Solidity, Viper, LLL and Serpent. These are the high level languages that are compiled down to bytecode.
Solidity and JavaScript. These are the official first implementations for distributed applications, and the blockchain fully supports those languages.
24. Solidity Gets Compiled ToâŠ
Bytecode that canât be understood by humans.
Bytecodes which are basically opcodes running instruction by instruction.
25. Gas Is UsedâŠ
Depending on the instruction/opcode run by the Ethereum blockchain.
Is a fixed amount for the length of your smart contract.
26. To Store Almost All Data In The Ethereum BlockchainâŠ
A linked list with pointers to previous blocks hashes is used.
A Merkle Patricia Trie is used.
A Radix Trie is used, because the Merkle Patricia Trie is too inefficient.
27. You Interact With A Smart Contract, And See A Gas Usage Of 50,000 Gas With A Gas Cost Of 15 Gwei. How Much Ether Would You Have To Pay To The Miner?
750,000,000,000,000 Wei.
750,000,000,000 Wei.
750,000,000 Wei.
A flat fee of 1 Ether.
28. Checking The Balance Of An Address Inside A Loop Of A Smart Contract ConstantlyâŠ
Doesnât cost any gas
Costs gas every time we check the balance.
29. Solidity FilesâŠ
Canât be split across multiple files, everything should be in one single file.
Can be split across multiple files, but every contract must be in a file with the same name as the contract itself.
Can be spread across multiple files. To import all contracts from a file you can use âimport / myfile.solâ. To import contract,= âMyContractâ from âmyfile.solâ use âimport from myfile.solâ.
30. Files Can BeâŠ
Imported using relative and absolute paths, where the â.â and the â..â depict that itâs a relative path.
Imported only via Github using the repository, and username.
Imported using the special requirefile(âŠ) statement, which looks in a specific library path to import files.
31. Importing From GitHubâŠ
Works across all compilers, and platforms the same way.
Is generally possible, but currently only works in Remix. Not in Truffle.
32. Single Line Comments In Solidity Are Working WithâŠ
Either // or ///
With /* comment */ or /** @.. natspec style */
33. Multi-Line Comments In Solidity Work WithâŠ
Either // or ///
With /* comment */ or /** @.. natspec style */
34. The Following Are Value Types In SolidityâŠ
Integer, Boolean, Struct, Mapping and Enum.
Integer, Boolean, Enum and Addresses.
Integer, Boolean, Structs and Fixed Point Numbers.
35. To Compare A String In Solidity You UseâŠ
String1 == string2.
The internal function âstr_compare(str1,str2)â.
You canât directly compare two strings, but one method would be to hash both strings then compare the hashes.
Bytes32(string1) == bytes32(string2).
36. If We Divide Two Integers: 5/2, The Result IsâŠ
2 â Because the decimal is truncated.
3 â Because itâs always rounded.
2.5 â Because itâs automatically converted into a float.
37. A Struct Is A Great WayâŠ
To define a new datatype in Solidity, so you donât need to use objects of another contract.
To hold instances of other contracts.
To implement pointers to other contracts that can hold new datatypes.
38. A Mapping Consists Of Keys & ValueâŠ
The keys can be anything, but the value canât be another mapping or struct.
The value can be anything, but the key cannot be another mapping, struct, integer or boolean.
The value can be anything, but the key cannot be another mapping, struct, enum or dynamically sized array.
39. To Iterate Through A Mapping YouâŠ
Can use the length parameter of the mapping.
You need an external helper variable.
You cannot iterate any mapping to make the overall language design more safe.
40. Function & Variable Visibility:
A function marked as internal cannot be called by other contracts, unless the function is used by a derived contract. Private functions cannot be called by any other outside contract, and public variables are generating automatically a getter function.
A function that is marked as external can never be called internally. Private functions can also be called by derived contracts using inheritance. Private variables are accessible also in derived contracts.
41. View & Pure Functions:
A function marked as pure can change the state, while a view function can only return static calls.
A function marked as view can never access state variables, while pure functions are here to return only one value.
A view function can access state variables, but not write to them. A pure function cannot modify, or read from state.
42. View & Pure Functions:
Can only be accessed during calls.
Can be accessed during transactions and call.
43. The Fallback FunctionâŠ
Cannot receive Ether, not even by adding the payable modifier.
Can contain as much logic as you want, but itâs better to keep it short and not exceed the gas stipend of 2300 gas.
Can be used to avoid receiving ether.
44. To Get The Address That Initiated The Transaction You Need To UseâŠ
Tx.origin
Msg.sender
45. If A User Calls Contract A & That Calls Contract B, Then Msg.Sender In Contract B Will Contain The Address OfâŠ
The User.
Contract A.
46. Loops InSolidityâŠ
Are a great way to circumvent gas requirements, because a loop will only consume gas once.
Are dangerous when used with datastructures that grow such as arrays or mapping, because itâs hard to estimate the gas requirements.
Should be avoided where possible, due to unknown effects on gas requirements.
47. EventsâŠ
Are stored on chain, and are a great way to get a return value when a contract calls another contract.
Are stored in something like a side-chain, and cannot be accessed by contracts.
Are used primarily for debugging exceptions in Solidity.
48. According To The Official Style GuideâŠ
You should capitalise function names, events and contract names to avoid confusion with JavaScript. You should use tabs to indentation, and a maximum of 80 characters per line.
Contract names should be capitalised, while functions should be mixedCase. You should use 4 spaces as indentation, and a maximum of 79 (or 99) characters per line.
Contracts should be mixedCase, as well as function names. Events should be capitalised. 2 spaces should be used as indentation, and a maximum of 120 characters per line.
49. A Version Pragma Is A Great WayâŠ
To make it clear for which compiler version a smart contract was developed for. It helps to avoid breaking changes.
To make it clear for which blockchain a smart contract was developed for. It helps to avoid confusion with beta-customers.
To make it clear for which blockchain node a smart contract was developed for. It helps to avoid mixing up different versions of go-ethereum.
50. Variables Of The Type Address StoreâŠ
A 20 bytes value.
A 32 bytes value.
A string.
A 20 characters long hex number.
51. Whatâs the difference between ERC and EIP?
Ethereum Request for Comments (ERC) are here to define standards for the usage of Ethereum. Ethereum Improvement Proposals (EIP) are here to improve the Ethereum Protocol itself.
Ethereum Request for Comments (ERC) are here to propose new distributed applications on top of the Ethereum layer, while Ethereum Improvement Proposals (EIP) are here t improve existing mining software.
Ethereum Request for Comments (ERC) are an open platform to discuss continuous forking of the Ethereum platform. Successful forks are then incorporated in the Ethereum Improvement Proposals (EIP) for further voting by the Ethereum Consortium.
52. What is the difference between ERC20 and ERC721 Tokens in simple terms?
The tokens of a certain ERC20 symbol are all the same, the tokens of an ERC721 symbol are all different. So, ERC20 tokens are fungible, while ERC721 tokens are non-fungible.
The tokens of a certain ERC20 symbol are all different, the tokens of an ERC721 symbol are all the same. So, ERC20 tokens are non-fungible while ERC721 tokens are fungible.
The ERC20 token standard was the first standard token contract out there which got superseded by ERC721 tokens in order to support different token standards. One of the token standards that were necessary was non-fungible tokens. Since ERC721 tokens exist there is no need for ERC20 tokens anymore.
53. In order to implement an ERC20 token contract, youâd need at least to implement the following functions and events in order to fulfill the interface requirements:
totalSupply(), balanceOf(address), allowance(address,address), transfer(address,uint256), approve(address,uint256), transferFrom(address,address,uint256). Events: Transfer(address,address,uint256), Approval(address,address,uint256)
name(), symbol(), totalSupply(), balanceOf(address), ownerOf(uint26),approve(address,uint256), takeOwnership(uint256),transfer(address,uint256),Events: Transfer(address,address,uint256), Approval(address,address,uint256)
54. If Contract MyContractA Is Derived From Contract MyContractB, Then This Would Be The Right Syntax:
contract MyContractA is MyContractB
contract MyContractA inherit (MyContractB)
contract MyContractA extends MyContractB
contract MyContractB derives MyContractA
55. Inheritance Is Useful, Because A Contract That Is Derived From Another Contract Can Make Use OfâŠ
All public state variables and properties, public and internal functions, and modifiers.
All public and private state variables, public, internal and external functions, but not modifiers.
All public state variables and properties, public functions and modifiers, but not internal, external or private ones.
56. Finish The Sentence: The Library Web3.js IsâŠ
Useful when developing distributed applications with HTML and JavaScript, because it already implements the abstraction of the JSON-RPC interface of Ethereum nodes.
Necessary when developing distributed applications with HTML and JavaScript, because the proprietary JSON-RPC interface of Ethereum nodes is closed source.
A great way to start with a boilerplate distributed application. Web3.js give you a lot of options to start either with React or Vue.js apps.
57. When Solidity Is Compiled Then Also Metadata Is GeneratedâŠ
The metadata contains the ABI Array, which defines the interface to interact with the smart contract. Metadata can also contain the address of the smart contract when it gets deployed.
Metadata contains the address, and the size of the smart contract. The ABI Array is generated externally upon deploying the smart contract.
The ABI array and the Metadata are not generated when solidity is compiled to bytecode, its generated by a migration software which deploys the smart contract on the blockchain.
58. The Difference Between Address.Send() & Address.Transfer() IsâŠ
.send returns a Boolean, and .transfer throws an exception on error. Both just forward the gas-stipend of 2300 gas, and are considered safe against re-entrancy.
send throws an exception, and .transfer returns a Boolean on error. Both just forward the gas-stipend of 2300 gas, and considered safe against re-entrancy.
.send returns a Boolean, and .transfer throws an exception on error. .send is considered dangerous, because it sends all gas along while .transfer only sends the gas stipend of 2300 gas along.
.send and .transfer are both considered low-level functions which are dangerous, because they send all gas along. Itâs better to use address.call.value()() to control the gas-amount.
59. All Low-Level Functions On The Address, So Address.Send(), Address.Call.Value()(), Address.Callcode & Address.DelegatecallâŠ
Are interrupting execution on error, because they throw an exception.
Continuing execution on error silently, which is why theyâre dangerous.
Returning Booleans to indicate an error during execution.
.send() throws an exception, while the other functions are returning Booleans during execution to indicate an error.
60. When Using Assert To Check Invariants & It Evaluates To FalseâŠ
All gas is consumed.
All remaining gas is returned.
61. When Using Require To Check Input Parameters & It Evaluates To FalseâŠ
All gas is consumed.
All remaining gas is returned.
62. To Send Ether To A Contract Without A Function Call:
A fallback function must be declared, and it must be made payable. If there is no fallback function or the fallback function is not payable, it will throw an exception
Either a fallback function which is payable exists, or no fallback function exists.
You cannot send ether to a contract without explicitly calling a function. The fallback function can never receive ether.
63. Using Selfdestruct(Beneficiary) With The Beneficiary Being A Contract Without A Payable Fallback Function:
Will throw an exception, because the fallback function is non-payable thus cannot receive ether.
Itâs impossible to secure a contract against receiving ether, because selfdestruct will always send ether to the address in the argument. This is a design decision of the Ethereum platform.
Selfdestruct doesnât send anything to a contract, it just re-assigns the owner of the contract to a new person. Sending ether must be done outside of selfdestruct.
64. If You Need More Fine-Grained Functionality Than Solidity Offers Out Of The BoxâŠ
You can incorporate inline-assembly to get better controls.
You have to import pre-compiled assembly files, which are then hard-copied into the bytecode of the compiled Solidity file.
You can use Viper, the experimental assembly like language specifically to offer more flexibility.
65. .Call vs. Delegatecall:
Address.call() is used for calling other contracts, using the scope of the called contract in terms of storage variables. Address.delegatecall() is used for libraries, which uses the storage variables of the contract who called. Libraries are a great way to re-use already existing code, and delegatecall can make sure that no storage is used from the library, instead it looks like the code is directly copied into the calling contract.
Address.delegatecall() is used for calling other contracts, using the scope of the called contract in terms of storage variables. Address.call() is used for libraries, which uses the storage variables of the contract who called. Libraries are a great way to re-use already existing code, and call() can make sure that no storage is used from the library, instead it looks like the code is directly copied into the calling contract.
66. Truffle:
Is a framework that helps developers with testing, deployment and management of smart contracts and distributed applications.
Is a library that helps developers to connect to Ethereum nodes, because it abstracts the JSON-RPC interface.
Is a framework for Java, similar to Web3.js for JavaScript. Itâs a great way to develop distributed java enterprise applications.
67. Unit-Testing On A Local Chain Is Important, Because It HelpsâŠ
Run tests is an environment where logging is activated. On the main-net you have no access to transaction logs, and this is ultimately the information you need to debug your contracts.
Avoid regression bugs with contracts that are updated constantly on the main-net. Once you update a contract on the main-net, the address stays the same but the code changes, and this can have disastrous side-effects.
Run tests quickly for free, compared to continuous deployment on the main-network. This way you save a lot of fees, time and costs.
68. With Truffle Itâs Easy To Write Clean Room Unit TestsâŠ
For Java, JavaScript, and C++.
For Solidity and JavaScript.
For JavaScript using Web3.js.
For any language, as long as it adheres to the open testing interface from Truffle.
69. With The Truffle Config File You Can ManageâŠ
The amount of gas your contract deployment and transactions against your contract will need. This way you can essentially lower the gas costs over traditional web3.js dApps.
Different networks to deploy your contracts to. This way you can easily deploy to a local blockchain, the main-net or the Ropsten/Rinkeby test-net with only one parameter.
You can manage your secret API keys to the Ethereum network. This way you can get access to several different Ethereum nodes at the same time, without the need to switch your keyfiles.
70. Why Is Unit-Testing So Important?
It helps you find bugs, regression bugs, and sometimes helps you to understand your code from different angles.
It is a great way to spend time on something that you get paid for. But ultimately it will just slow down the development process.
71. If You Are Starting A New ERC20 TokenâŠ
It would be best to start from scratch, just looking at the required interface.
It is beneficial to copy/paste the already existing code from the Ethereum wiki, and modify this until you like it.
Best is to start with an audited implementation, for example from OpenZeppelin, in order to re-use already existing code.
72. To Generate A Random NumberâŠ
Itâs good to use the block timestamp, as this is always different.
Itâs good to use the block hash, as this is clearly always very different.
Itâs good to use the RANDAO smart contract.
Itâs not possible to have a random number in a deterministic environment, such as the Ethereum blockchain.
73. When You Do External Calls To Other Smart ContractsâŠ
You should follow the effects-checks-interactions pattern, and avoid state changes before the call.
You should follow the checks-effects-interactions pattern, and avoid state changes after the call.
You should follow the checks-effects-interactions pattern, which is only necessary when you do calls to contracts where a direct contract call is not possible.
74. When You Are Programming A Game Like Poker Of Battleships Where You Need To Hide Opponents Values IsâŠ
With private state variables. This way nobody else than the smart contract itself can see the information.
With external contracts holding those values. This way we can make sure that the information flow is following clear logic, and nobody else can access information.
You canât hide anything on the blockchain, because the information is public just the call is private which means only other smart contracts would be limited in accessing that information.
75. When Considering Smart Contracts & The Blockchain Itâs GoodâŠ
To move all existing logic to the blockchain, so everything runs on the same system. This way it might be more complex, but easier to maintain.
To move only those parts to the blockchain that really need one. This way smart contracts can be easier to read, easier to test and are not so complex.
To move those parts to the blockchain that deal with Ether transfers. All other parts can remain in traditional database systems. This way only the value-transfer is on the blockchain.
76. When A Smart Contract Pays Out MoneyâŠ
Itâs good to use a push over a pull method.
Itâs good to use a push and a pull method to ensure that participants can get their money no matter the contract state. In addition to and pushing it should contain a withdraw method.
Itâs good to use only pull and no push method.
77. To Develop Smart Contracts:
Itâs good to start with a local in-memory blockchain with unit tests, but then deploy to the main-net as rapidly as possible.
Itâs good to start with a local in-memory blockchain with unit-tests. Then in the next step, debug and test the smart contract on a test-net like Ropsten or Rinkeby with beta customers, ironing out last issues before deploying it to the main-net.
Itâs good to start with a test-net with beta-customers like on the Rinkeby or Ropsten test-net, before testing it locally on an in-memory blockchain simulation such as Ganache. Then deploy it to the main-net.
78. To Avoid Issues During Ethereum Platform UpgradesâŠ
Itâs good to inform users about the updates via a newsletter.
Itâs good to have the ability to pause a contract in order to manage the money at risk.
Ethereum doesnât upgrade the platform. Itâs fixed and final.
Published at Tue, 20 Aug 2019 13:58:05 +0000
Bitcoin Pic Of The Moment
By CashlessWay – Global Hub for ePayment Culture on 2014-06-28 09:38:58
