What is Web3.js?
A JavaScript library that allows web applications to interact with the Ethereum blockchain.
Basic Setup:
html
<script src=”https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js”></script>
<script>
const web3 = new Web3(Web3.givenProvider || “http://localhost:8545”);
</script>
Connecting to MetaMask:
javascript
await window.ethereum.request({ method: ‘eth_requestAccounts’ });