Model Question Paper
Model Question Paper
This exam contains 17 pages (including this cover page) and 5 questions.
Total of points is 119.
Rest of introduction. Rest of introduction. Rest of introduction. Rest of introduction.
Rest of introduction. Rest of introduction. Rest of introduction. Rest of introduction.
(a) D
(b) (3 points) what are the pillars of blockchain technology ?
A. Decentralization.
B. Scalability.
C. Immutability.
D. All of the above.
(b) D
(c) (3 points) receive verify, gather and execute transactions.
A. Miner nodes.
B. Smart Contracts.
C. Light wallets.
D. Ethereum full node.
(c) A
(d) (3 points) Smart Contract characteristics do not include:
A. Alterable
B. Fast and cost-effective
C. A high degree of accuracy
D. Transparency
(d) A
(e) (3 points) A popular public-private key implementation known as Rivest-Shamir
Adelman (RSA) algorithm is used for the Bitcoin and Ethereum Blockchain.
A. True
B. False
(e) B
(f) (3 points) What blockchain is considered Blockchain 1.0, the first blockchain?
A. Bitcoin Cash.
B. Ethereum.
CSIT6000Q (L1) Sample Question Paper - Page 3 of 17 25/11/2023
C. Litecoin.
D. Bitcoin.
E. NEO.
(f) D
(g) (3 points) What powers the Ethereum Virtual Machine?
A. Gas.
B. Ether.
C. Block Reward.
D. Mining Reward.
(g) A
(h) (3 points) Is syntax pragma Correct?
pragma solidity >=0.4.20 <0.4.25;
A. Correct.
B. Incorrect.
(h) A
(i) (3 points) How much does the self-destruct function cost in gas?
A. 5000.
B. 2100.
C. 3000.
D. 2800.
(i) A
(j) (3 points) What is the result when the following code compiles and deploy?
[Link] solidity >=0.8.2 <0.9.0;
[Link] A {
[Link] getNumber () public returns (uint8){
4. return 1;
5. }
6. }
[Link] B is A {
8. function getNumber () public returns (uint8){
9. return 1;
10. }
11. }
A. Compilation succeeds .
B. An error at line 3 causes compilation to fail.
CSIT6000Q (L1) Sample Question Paper - Page 4 of 17 25/11/2023
(j) B
(k) (3 points) What is the result when the following code compiles and deploy?
[Link] solidity >=0.8.2 <0.9.0;
2.
[Link] A {
4. function getNumber () public virtual returns (uint8){
5. return 1;
6. }
7. }
[Link] B is A {
9. function getNumber () public returns (uint8){
11. return 1;
12. }
13. }
A. Compilation succeeds.
B. An error at line 3 causes compilation to fail.
C. An error at line 8 causes compilation to fail.
D. Compilation succeeds but an exception is thrown at line 8.
(k) C
(l) (3 points) What is the result when the following code compiles and deploy?
[Link] solidity >=0.8.2 <0.9.0;
2.
[Link] A {
4. function getNumber () public virtual returns (uint8){
5. return 1;
6. }
7. }
[Link] B is A {
9. function getNumber () public override returns (uint8){
11. return 1;
12. }
13. }
A. Compilation succeeds.
B. An error at line 3 causes compilation to fail.
C. An error at line 8 causes compilation to fail.
D. Compilation succeeds but an exception is thrown at line 8.
(l) A
CSIT6000Q (L1) Sample Question Paper - Page 5 of 17 25/11/2023
(m) D
(n) (3 points) Which of the following statements is true for contract A?
1.# @version ^0.2.16
2.
[Link]: public(String[100])
4.
5.@external
[Link] __init__():
7. greet = "Hello World"
A. Compilation succeeds.
B. An error at line 1 causes compilation to fail.
C. An error at line 2 causes compilation to fail.
D. An error at line 7 causes compilation to fail.
(n) D
(o) (3 points) Which of the following are true about Solidity vs Vyper:
A. Vyper has less feature compared to Solidity.
B. Vyper is more secured .
C. Both support Structs.
D. All of the above.
(o) D
Solution:
Integer Overflow at 14 and 15.
(b) (6 points) Is the following smart contract safe? If not, what type of vulnerability
associated it with.
1 contract MarketPlace {
2 uint public price ;
3 uint public stock ;
4 /.../
5 function updatePrice ( uint _price ){
6 if ( msg . sender == owner )
7 price = _price ;
8 }
9 function buy ( uint quant ) returns ( uint ){
10 if ( msg . value < quant * price || quant > stock )
11 throw ;
12 stock -= quant ;
13 /.../
14 }}
Solution: A contract that acts as a market place where users can buy/ sell
some tokens. Due to TOD, some order may or may not go through.
(c) (5 points) Is the following smart contract safe? If not, what type of vulnerability
CSIT6000Q (L1) Sample Question Paper - Page 7 of 17 25/11/2023
associated it with.
1 contract theRun {
2 uint private Last_Payout = 0;
3 uint256 salt = block . timestamp ;
4 function random returns ( uint256 result ){
5 uint256 y = salt * block . number /( salt %5);
6 uint256 seed = block . number /3 + ( salt %300)
7 + Last_Payout +y;
8 // h = the blockhash of the seed - th last block
9 uint256 h = uint256 ( block . blockhash ( seed ));
10 // random number between 1 and 100
11 return uint256 (h % 100) + 1;
12 }}
Solution:
contract which depends on block timestamp to
send out money.
(d) (5 points) Is the following smart contract safe? If not, what type of vulnerability
associated it with.
1 contract KingOfTheEtherThrone {
2 struct Monarch {
3 // address of the king .
4 address ethAddr ;
5 string name ;
6 // how much he pays to previous king
7 uint claimPrice ;
8 uint coronationTimestamp ;
9 }
10 Monarch public currentMonarch ;
11 // claim the throne
12 function claimThrone ( string name ) {
13 /.../
14 if ( currentMonarch . ethAddr != wizardAddress )
15 currentMonarch . ethAddr . send ( compensation );
16 /.../
17 // assign the new king
18 currentMonarch = Monarch (
19 msg . sender , name ,
20 valuePaid , block . timestamp );
21 }}
CSIT6000Q (L1) Sample Question Paper - Page 8 of 17 25/11/2023
Solution: A code snippet of a real contract which does not check the return
value after calling other contracts
// Defining a constructor
constructor(string memory str_in){
str = str_in;
}
// Defining a function to return value of variable ’str’
function str_out() public view returns(string memory){
return str;
}
}
Solution:
Yes
Attribute Data
time 2015-09-27 22:51
number 300248
gas limit 3141592
gas used 0
difficulty 7132374666666
total difficulty 1403681940690798318
size 549
base fee per gas
hash 0x075bf83f88c422b32346e3fb47f5bfbab4ca0be38d64ffd5f05ecd6602770cf9
parent hash 0x2691fef8655dd9ed8c9f6ec43da3cda4c69ba85b0688d0cd04ac1d939875b4f5
miner 0x22a0fbf89ad1362d74f626436d8c4fc6dc4f0679
nonce 0x9c63b62f9c0e6a07
date 2015-09-27
CSIT6000Q (L1) Sample Question Paper - Page 9 of 17 25/11/2023
Solution:
SELECT
DATE_TRUNC(’day’,time) AS dt
, COUNT(*) AS num_blocks
FROM [Link]
WHERE
time >= (DATE_TRUNC(’day’,CURRENT_TIMESTAMP) - ’90 days’::INTERVAL)
AND time <= DATE_TRUNC(’day’,CURRENT_TIMESTAMP)
GROUP BY 1
ORDER BY 1;
interface GeometricObject{
}
interface Comparable{
interface Cloneable{
}
contract Hexagon is GeometricObject, Comparable, Cloneable{
constructor(uint256 _side){
side=_side;
}
return 3*[Link](3)*side*side;
return 6*side;
(e) (6 points) Implement the clone [Link] that [Link]() will set a new hexagon
with the same size as X.
function clone(address objAddress) public returns(GeometricObject) {
return newHexagonAddress;
}
CSIT6000Q (L1) Sample Question Paper - Page 11 of 17 25/11/2023
@public
@constant
def delegated(addr: address) -> bool:
return [Link][addr].delegate != ZERO_ADDRESS
@public
@constant
def directlyVoted(addr: address) -> bool:
return [Link][addr].voted and ([Link][addr].delegate ==
ZERO_ADDRESS)
CSIT6000Q (L1) Sample Question Paper - Page 12 of 17 25/11/2023
target: address =
[Link][delegate_with_weight_to_forward].delegate
for i in range(4):
if [Link](target):
target = [Link][target].delegate
# The following effectively detects cycles of length <= 5,
# in which the delegation is given back to the delegator.
# This could be done for any int128ber of loops,
# or even infinitely with a while loop.
# However, cycles aren’t actually problematic for correctness;
# they just result in spoiled votes.
# So, in the production version, this should instead be
# the responsibility of the contract’s client, and this
# check should be removed.
CSIT6000Q (L1) Sample Question Paper - Page 13 of 17 25/11/2023
weight_to_forward: int128 =
[Link][delegate_with_weight_to_forward].weight
[Link][delegate_with_weight_to_forward].weight = 0
[Link][target].weight += weight_to_forward
if [Link](target):
[Link][[Link][target].vote].voteCount +=
weight_to_forward
[Link][target].weight = 0
[Link][[Link]].voted = True
[Link][[Link]].delegate = to
# This call will throw if and only if this delegation would cause a
loop
# of length <= 5 that ends up delegating back to the delegator.
[Link]([Link])
[Link][[Link]].vote = proposal
[Link][[Link]].voted = True
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/// @title Voting with delegation.
contract Ballot {
// This declares a new complex type which will
// be used for variables later.
// It will represent a single voter.
struct Voter {
uint weight; // weight is accumulated by delegation
bool voted; // if true, that person already voted
address delegate; // person delegated to
uint vote; // index of the voted proposal
}
if (delegate_.voted) {
// If the delegate already voted,
// directly add to the number of votes
CSIT6000Q (L1) Sample Question Paper - Page 17 of 17 25/11/2023
proposals[delegate_.vote].voteCount += [Link];
} else {
// If the delegate did not vote yet,
// add to her weight.
delegate_.weight += [Link];
}
}