0
0
Blockchain / Solidityprogramming~10 mins

Sidechains in Blockchain / Solidity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a sidechain name.

Blockchain / Solidity
sidechain_name = "[1]"
Drag options to blanks, or click blank then click option'
Amainchain
Bblockchain
Csidechain1
Dtokenchain
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mainchain' instead of a sidechain name
Using generic terms like 'blockchain' that don't specify sidechain
2fill in blank
medium

Complete the code to initialize the sidechain block height.

Blockchain / Solidity
sidechain_block_height = [1]
Drag options to blanks, or click blank then click option'
A"0"
B0
CNone
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string '0' instead of integer 0
Using None or negative numbers
3fill in blank
hard

Fix the error in the function that checks if a block belongs to the sidechain.

Blockchain / Solidity
def is_sidechain_block(block):
    return block.chain_id == [1]
Drag options to blanks, or click blank then click option'
Asidechain_id
B"sidechain"
C"mainchain"
Dblock.chain_id
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing to a string literal instead of the sidechain ID variable
Comparing the variable to itself
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps block hashes to their heights only for sidechain blocks.

Blockchain / Solidity
sidechain_blocks = {block.hash: block.[1] for block in blocks if block.chain_id [2] sidechain_id}
Drag options to blanks, or click blank then click option'
Aheight
B!=
C==
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' instead of '==' in the condition
Using 'index' instead of 'height' for block attribute
5fill in blank
hard

Fill all three blanks to create a function that returns a list of sidechain block hashes with height greater than a given value.

Blockchain / Solidity
def get_sidechain_hashes(min_height):
    return [block.[1] for block in blocks if block.chain_id == [2] and block.[3] > min_height]
Drag options to blanks, or click blank then click option'
Ahash
Bsidechain_id
Cheight
Dtimestamp
Attempts:
3 left
💡 Hint
Common Mistakes
Using timestamp instead of height for comparison
Comparing to wrong chain ID variable