Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a batch of transactions using the correct method.
Blockchain / Solidity
const batch = new web3.[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent class like TransactionBatch.
Confusing batch operations with single transactions.
✗ Incorrect
The BatchRequest class is used to create a batch of requests in web3.js.
2fill in blank
mediumComplete the code to add a transaction call to the batch.
Blockchain / Solidity
batch.[1](contract.methods.transfer(toAddress, amount), callback); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
send which executes immediately instead of adding to batch.Using
push which is not a method of batch.✗ Incorrect
The add method is used to add a request to the batch.
3fill in blank
hardFix the error in the code to execute the batch of transactions.
Blockchain / Solidity
batch.[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
send which is for single transactions.Using
run or process which do not exist.✗ Incorrect
The execute method runs all requests in the batch.
4fill in blank
hardFill both blanks to create a batch and add a call to get the balance.
Blockchain / Solidity
const batch = new web3.[1](); batch.[2](contract.methods.balanceOf(userAddress), callback);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
send instead of add to add calls.Confusing batch creation with execution.
✗ Incorrect
First, create a BatchRequest object, then add the balanceOf call to the batch.
5fill in blank
hardFill all three blanks to create a batch, add two calls, and execute the batch.
Blockchain / Solidity
const batch = new web3.[1](); batch.[2](contract.methods.approve(spender, amount), callback); batch.[3](contract.methods.allowance(owner, spender), callback); batch.execute();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
send instead of add to add calls.Trying to execute the batch before adding calls.
✗ Incorrect
Create a BatchRequest, then add each call to the batch before executing.