0
0
Blockchain / Solidityprogramming~10 mins

First smart contract deployment 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 a smart contract named MyContract.

Blockchain / Solidity
contract [1] {
    // contract code
}
Drag options to blanks, or click blank then click option'
AMyContract
Bmycontract
CContract1
DSmartContract
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase names for the contract.
Using generic names like Contract1.
2fill in blank
medium

Complete the code to define a public state variable named owner of type address.

Blockchain / Solidity
address public [1];
Drag options to blanks, or click blank then click option'
Aowner
Bcreator
Cuser
Dadmin
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic names like admin or user instead of owner.
Forgetting to declare the variable as public.
3fill in blank
hard

Fix the error in the constructor to set the owner to the address that deploys the contract.

Blockchain / Solidity
constructor() {
    [1] = msg.sender;
}
Drag options to blanks, or click blank then click option'
Aaddress owner
Bowner
Cowner()
Dmsg.sender
Attempts:
3 left
💡 Hint
Common Mistakes
Using owner() which looks like a function call.
Trying to redeclare the variable inside the constructor.
4fill in blank
hard

Fill both blanks to create a function named getOwner that returns the owner address.

Blockchain / Solidity
function [1]() public view returns ([2]) {
    return owner;
}
Drag options to blanks, or click blank then click option'
AgetOwner
Baddress
Cowner
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect return types like string.
Naming the function something unrelated.
5fill in blank
hard

Fill all three blanks to deploy the contract and assign the owner correctly.

Blockchain / Solidity
contract [1] {
    address public [2];
    constructor() {
        [3] = msg.sender;
    }
}
Drag options to blanks, or click blank then click option'
AMyContract
Bowner
Cadmin
Dcreator
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for the owner variable in different places.
Forgetting to assign the owner in the constructor.