0
0
Blockchain / Solidityprogramming~10 mins

Event testing 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 emit an event named Transfer.

Blockchain / Solidity
emit [1](msg.sender, recipient, amount);
Drag options to blanks, or click blank then click option'
ADeposit
BApproval
CTransfer
DWithdraw
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong event name like Approval instead of Transfer.
Forgetting to emit the event.
2fill in blank
medium

Complete the code to listen for the Approval event in a test.

Blockchain / Solidity
const filter = contract.filters.[1](owner, spender);
Drag options to blanks, or click blank then click option'
AWithdraw
BApproval
CDeposit
DTransfer
Attempts:
3 left
💡 Hint
Common Mistakes
Using Transfer event filter when testing Approval.
Misspelling the event name.
3fill in blank
hard

Fix the error in the test assertion for event arguments.

Blockchain / Solidity
expect(event.args.[1]).to.equal(recipient);
Drag options to blanks, or click blank then click option'
Asender
Bowner
Camount
Drecipient
Attempts:
3 left
💡 Hint
Common Mistakes
Using sender instead of recipient for the receiver address.
Confusing argument names.
4fill in blank
hard

Fill both blanks to filter events by sender and minimum amount.

Blockchain / Solidity
const filter = contract.filters.Transfer([1], null, [2]);
Drag options to blanks, or click blank then click option'
AsenderAddress
BrecipientAddress
CminAmount
DmaxAmount
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping sender and recipient addresses.
Using maxAmount instead of minAmount.
5fill in blank
hard

Fill all three blanks to assert event emission with correct args.

Blockchain / Solidity
await expect(tx).to.emit(contract, '[1]').withArgs([2], [3], amount);
Drag options to blanks, or click blank then click option'
ATransfer
BsenderAddress
CrecipientAddress
DApproval
Attempts:
3 left
💡 Hint
Common Mistakes
Using Approval event instead of Transfer.
Swapping sender and recipient arguments.