0
0
Blockchain / Solidityprogramming~10 mins

ERC-1155 multi-token standard 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 ERC-1155 contract inheritance.

Blockchain / Solidity
contract MyToken is [1] {
    // contract code
}
Drag options to blanks, or click blank then click option'
AERC20
BERC1155
CERC721
DOwnable
Attempts:
3 left
💡 Hint
Common Mistakes
Using ERC20 or ERC721 inheritance instead of ERC1155.
Forgetting to inherit any contract.
2fill in blank
medium

Complete the code to mint a new token with a specific ID and amount.

Blockchain / Solidity
function mintToken(address to, uint256 id, uint256 amount) public {
    _mint(to, id, [1], "");
}
Drag options to blanks, or click blank then click option'
Aid
Bmsg.sender
Camount
Dto
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the recipient address instead of amount.
Passing the token ID instead of amount.
3fill in blank
hard

Fix the error in the transfer function call by completing the missing argument.

Blockchain / Solidity
safeTransferFrom(msg.sender, to, id, amount, [1]);
Drag options to blanks, or click blank then click option'
A""
Baddress(0)
C0x0
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Using null or zero address instead of empty bytes.
Omitting the last parameter.
4fill in blank
hard

Fill both blanks to create a mapping for balances of token IDs per address.

Blockchain / Solidity
mapping(address => mapping(uint256 => [1])) private [2];
Drag options to blanks, or click blank then click option'
Auint256
Baddress
Cbalances
Dbool
Attempts:
3 left
💡 Hint
Common Mistakes
Using address or bool as the value type.
Incorrect variable name.
5fill in blank
hard

Fill all three blanks to implement a function that returns the URI for a given token ID.

Blockchain / Solidity
function uri(uint256 [1]) public view override returns (string memory) {
    return string(abi.encodePacked([2], Strings.[3]([1]), ".json"));
}
Drag options to blanks, or click blank then click option'
AtokenId
BbaseURI
CtoString
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong parameter names.
Forgetting to convert the token ID to string.