0
0
Blockchain / Solidityprogramming~10 mins

Sending transactions 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 send a transaction using the web3 library.

Blockchain / Solidity
const tx = {
  from: senderAddress,
  to: receiverAddress,
  value: web3.utils.toWei('1', '[1]')
};
Drag options to blanks, or click blank then click option'
Aether
Bwei
Cgwei
Dtoken
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'wei' directly without conversion.
Using 'gwei' which is a smaller unit.
Using an invalid unit like 'token'.
2fill in blank
medium

Complete the code to sign the transaction with the private key.

Blockchain / Solidity
const signedTx = await web3.eth.accounts.signTransaction(tx, [1]);
Drag options to blanks, or click blank then click option'
AtransactionHash
BreceiverAddress
CsenderAddress
DprivateKey
Attempts:
3 left
💡 Hint
Common Mistakes
Using the sender's address instead of the private key.
Using the receiver's address.
Using the transaction hash which is not available yet.
3fill in blank
hard

Fix the error in sending the signed transaction.

Blockchain / Solidity
web3.eth.sendSignedTransaction([1].rawTransaction)
  .on('receipt', console.log);
Drag options to blanks, or click blank then click option'
AsignedTx
Btx
Ctransaction
Dreceipt
Attempts:
3 left
💡 Hint
Common Mistakes
Using the original transaction object instead of the signed one.
Using undefined variables.
Using the receipt object before sending.
4fill in blank
hard

Fill both blanks to create a transaction object with gas and gasPrice.

Blockchain / Solidity
const tx = {
  from: senderAddress,
  to: receiverAddress,
  value: web3.utils.toWei('0.5', 'ether'),
  gas: [1],
  gasPrice: web3.utils.toWei('[2]', 'gwei')
};
Drag options to blanks, or click blank then click option'
A21000
B50
C100000
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using too low gas limit causing transaction failure.
Using gas price in wei instead of gwei.
Confusing gas and gasPrice values.
5fill in blank
hard

Fill all three blanks to create a transaction receipt handler.

Blockchain / Solidity
web3.eth.sendSignedTransaction(signedTx.rawTransaction)
  .on('[1]', (receipt) => {
    console.log('Transaction [2] with hash:', receipt.[3]);
  });
Drag options to blanks, or click blank then click option'
Areceipt
Bconfirmation
CtransactionHash
Derror
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'error' event instead of 'receipt'.
Logging wrong receipt properties.
Confusing event names.