0
0
Blockchain / Solidityprogramming~10 mins

Minimal proxy (clone) pattern 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 declare the minimal proxy contract address variable.

Blockchain / Solidity
address public [1];
Drag options to blanks, or click blank then click option'
Aowner
Bimplementation
Cproxy
Dclone
Attempts:
3 left
💡 Hint
Common Mistakes
Using owner or proxy as the variable name instead of implementation.
2fill in blank
medium

Complete the code to create a minimal proxy clone using assembly.

Blockchain / Solidity
assembly {
  let clone := create(0, [1], 0x37)
}
Drag options to blanks, or click blank then click option'
A0x3d602d80600a3d3981f4
B0x602d80600a3d3981f3
C0x3d602d80600a3d3981f3
D0x3d602d80600a3d3981f2
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect bytecode length or wrong last byte in the sequence.
3fill in blank
hard

Fix the error in the function that returns the address of the clone.

Blockchain / Solidity
function getClone() public view returns (address) {
  return [1];
}
Drag options to blanks, or click blank then click option'
Aaddress(this)
BcloneAddress
Cimplementation
Dclone
Attempts:
3 left
💡 Hint
Common Mistakes
Returning implementation instead of the clone address.
4fill in blank
hard

Fill both blanks to complete the clone creation and initialization.

Blockchain / Solidity
function cloneAndInit() external returns (address) {
  address [1];
  assembly {
    [2] := create(0, add(code, 0x20), mload(code))
  }
  require([1] != address(0), "Clone failed");
  return [1];
}
Drag options to blanks, or click blank then click option'
Aclone
BcloneAddress
DnewClone
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for declaration and assignment.
5fill in blank
hard

Fill all three blanks to complete the dictionary comprehension that maps clone addresses to owners.

Blockchain / Solidity
mapping(address => address) public [1];

function registerClone(address [2], address [3]) external {
  clones[[2]] = [3];
}
Drag options to blanks, or click blank then click option'
Aclones
BcloneAddr
CownerAddr
DcloneAddress
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent parameter names or mapping name.