0
0
Blockchain / Solidityprogramming~10 mins

Ethereum networks (mainnet, testnet) 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 connect to the Ethereum mainnet using Infura.

Blockchain / Solidity
const provider = new ethers.providers.JsonRpcProvider('[1]');
Drag options to blanks, or click blank then click option'
Ahttps://mainnet.infura.io/v3/YOUR-PROJECT-ID
Bhttps://rinkeby.infura.io/v3/YOUR-PROJECT-ID
Chttps://kovan.infura.io/v3/YOUR-PROJECT-ID
Dhttps://ropsten.infura.io/v3/YOUR-PROJECT-ID
Attempts:
3 left
💡 Hint
Common Mistakes
Using a testnet URL instead of mainnet URL.
2fill in blank
medium

Complete the code to check the current block number on the Rinkeby testnet.

Blockchain / Solidity
const provider = new ethers.providers.JsonRpcProvider('[1]');
const blockNumber = await provider.getBlockNumber();
Drag options to blanks, or click blank then click option'
Ahttps://rinkeby.infura.io/v3/YOUR-PROJECT-ID
Bhttps://mainnet.infura.io/v3/YOUR-PROJECT-ID
Chttps://goerli.infura.io/v3/YOUR-PROJECT-ID
Dhttps://sepolia.infura.io/v3/YOUR-PROJECT-ID
Attempts:
3 left
💡 Hint
Common Mistakes
Using mainnet or other testnet URLs.
3fill in blank
hard

Fix the error in the code to connect to the Goerli testnet.

Blockchain / Solidity
const provider = new ethers.providers.JsonRpcProvider('[1]');
Drag options to blanks, or click blank then click option'
Ahttps://goerli.infura.io/v2/YOUR-PROJECT-ID
Bhttps://goreli.infura.io/v3/YOUR-PROJECT-ID
Chttps://goerli.infura.io/v3/
Dhttps://goerli.infura.io/v3/YOUR-PROJECT-ID
Attempts:
3 left
💡 Hint
Common Mistakes
Misspelling 'goerli' as 'goreli'.
Using wrong version number in URL.
4fill in blank
hard

Fill both blanks to create a dictionary mapping network names to their Infura URLs.

Blockchain / Solidity
const networks = {
  'mainnet': '[1]',
  'sepolia': '[2]'
};
Drag options to blanks, or click blank then click option'
Ahttps://mainnet.infura.io/v3/YOUR-PROJECT-ID
Bhttps://rinkeby.infura.io/v3/YOUR-PROJECT-ID
Chttps://sepolia.infura.io/v3/YOUR-PROJECT-ID
Dhttps://goerli.infura.io/v3/YOUR-PROJECT-ID
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing testnet URLs with mainnet.
5fill in blank
hard

Fill all three blanks to filter and map testnet names with their URLs from a networks object.

Blockchain / Solidity
const testnets = Object.entries(networks)
  .filter(([[1], [2]]) => [3] !== 'mainnet')
  .map(([name, url]) => ({ name, url }));
Drag options to blanks, or click blank then click option'
Akey
Bname
Curl
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names in destructuring.
Filtering by url instead of name.