0
0
Blockchain / Solidityprogramming~10 mins

Testing with ethers.js 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 import ethers from the hardhat package.

Blockchain / Solidity
const { [1] } = require('hardhat');
Drag options to blanks, or click blank then click option'
Acontract
Bweb3
Cethers
Dprovider
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'web3' instead of 'ethers' in Hardhat tests.
2fill in blank
medium

Complete the code to deploy a contract named 'SimpleStorage'.

Blockchain / Solidity
const SimpleStorage = await ethers.getContractFactory([1]);
const simpleStorage = await SimpleStorage.deploy();
Drag options to blanks, or click blank then click option'
A'SimpleStorage'
B'Simple'
C'Storage'
D'StorageSimple'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect or partial contract names.
3fill in blank
hard

Fix the error in the test assertion to check if the stored value equals 42.

Blockchain / Solidity
expect(await simpleStorage.retrieve()).to.[1](42);
Drag options to blanks, or click blank then click option'
AtoBe
Bequals
Ceq
Dequal
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'equals' or 'toBe' which are not valid Chai methods.
4fill in blank
hard

Fill both blanks to wait for the deployment transaction to be mined.

Blockchain / Solidity
const tx = await simpleStorage.[1]();
await tx.[2]();
Drag options to blanks, or click blank then click option'
Astore
Bwait
Cdeploy
Dsend
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'deploy' or 'send' instead of 'store' for the function call.
5fill in blank
hard

Fill all three blanks to write a test that checks if the stored value updates correctly.

Blockchain / Solidity
it('updates stored value', async function() {
  const tx = await simpleStorage.[1](100);
  await tx.[2]();
  const result = await simpleStorage.[3]();
  expect(result).to.equal(100);
});
Drag options to blanks, or click blank then click option'
Astore
Bwait
Cretrieve
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'update' instead of 'store' or 'retrieve'.