Get started with web3 CDN

LGPL-3.0 licensed

Web3 is a popular library for interacting with decentralized applications built on the Ethereum blockchain.

Tags:
  • Ethereum
  • JavaScript
  • API

Stable version

Copied!

How to start using web3 CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with web3 CDN - cdnhub.io</title>
    <script src="https://cdn.cdnhub.io/web3/4.6.0/web3.min.js"></script>
</head>
<body>
    <script>
        if (window.ethereum) {
            window.web3 = new Web3(window.ethereum);
            window.ethereum.enable().then(() => {
                const account = window.web3.currentProvider.selectedAddress;
                console.log('Connected account:', account);
            });
        } else {
            window.web3 = new Web3('http://localhost:8545'); // Replace with your local Ethereum node URL
            console.log('No web3 provider detected. Please connect to a local Ethereum node.');
        }

        // Example of interacting with a simple contract
        const contractABI = [
            // Your contract ABI goes here
        ];
        const contractAddress = '0x1234567890123456789012345678901234567890'; // Replace with your contract address
        const contract = new window.web3.eth.Contract(contractABI, contractAddress);

        contract.methods.totalSupply().call((err, result) => {
            if (err) {
                console.error('Error fetching contract data:', err);
            } else {
                console.log('Contract total supply:', result);
            }
        });
    </script>
</body>
</html>
Copied!
Copied!

All versions

1.10.0 1.10.0-rc.0 1.10.1 1.10.1-rc.0 1.10.2 1.10.3 1.10.3-dev.0 1.10.4 1.10.4-dev.0 1.2.10 1.2.10-rc.0 1.2.11 1.2.2 1.2.3 1.2.4 1.2.7 1.2.7-rc.0 1.2.8 1.2.8-rc.0 1.2.8-rc.1 1.2.9 1.2.9-rc.0 1.3.0 1.3.0-rc.0 1.3.1 1.3.2 1.3.2-rc.2 1.3.3 1.3.4 1.3.4-rc.1 1.3.4-rc.2 1.3.5 1.3.5-rc.0 1.3.6 1.3.6-rc.1 1.3.6-rc.2 1.4.0 1.4.0-rc.0 1.5.0 1.5.0-rc.0 1.5.0-rc.1 1.5.1 1.5.1-rc.0 1.5.1-rc.1 1.5.2 1.5.2-rc.0 1.5.3 1.5.3-rc.0 1.6.0 1.6.0-rc.0 1.6.1 1.6.1-rc.0 1.6.1-rc.2 1.6.1-rc.3 1.7.0 1.7.0-rc.0 1.7.1 1.7.1-rc.0 1.7.2 1.7.2-rc.0 1.7.3 1.7.3-rc.0 1.7.4 1.7.4-rc.0 1.7.4-rc.1 1.7.4-rc.2 1.7.5 1.7.5-rc.0 1.7.5-rc.1 1.8.0 1.8.0-rc.0 1.8.1 1.8.1-rc.0 1.8.2 1.8.2-rc.0 1.9.0 1.9.0-rc.0 2.0.0-alpha 2.0.0-alpha.1 3.0.0-rc.0 3.0.0-rc.1 3.0.0-rc.4 3.0.0-rc.5 4.0.0-alpha.0 4.0.1 4.0.1-alpha.0 4.0.1-alpha.1 4.0.1-alpha.2 4.0.1-alpha.3 4.0.1-alpha.4 4.0.1-alpha.5 4.0.1-rc.0 4.0.1-rc.1 4.0.1-rc.2 4.0.2 4.0.2-dev.023f02d.0 4.0.2-dev.2130d22.0 4.0.2-dev.3f49e18.0 4.0.2-dev.51a59f9.0 4.0.2-dev.60b8ba9.0 4.0.2-dev.a2a232f.0 4.0.2-dev.ab0f4cb.0 4.0.2-dev.af57eae.0 4.0.2-dev.e8d579c.0 4.0.2-dev.f8a2533.0 4.0.3 4.0.3-dev.602dada.0 4.0.3-dev.a26a888.0 4.0.3-dev.d12dc7e.0 4.0.4-dev.0e5c53c.0 4.0.4-dev.0ee9bb4.0 4.0.4-dev.1361787.0 4.0.4-dev.4310419.0 4.0.4-dev.51bc03d.0 4.0.4-dev.51d087e.0 4.0.4-dev.6da17e1.0 4.0.4-dev.7d0a91d.0 4.0.4-dev.8958413.0 4.0.4-dev.933ef51.0 4.0.4-dev.ad377d1.0 4.0.4-dev.b771112.0 4.0.4-dev.b93934a.0 4.0.4-dev.e143157.0 4.0.4-dev.ebd0c57.0 4.0.4-dev.ed2770c.0 4.0.4-dev.f5b4d7d.0 4.1.0 4.1.0-rc.0 4.1.1 4.1.1-dev.1cdc86c.0 4.1.1-dev.622174c.0 4.1.1-dev.7a38fee.0 4.1.1-dev.86f0cdb.0 4.1.1-dev.a4cae6f.0 4.1.1-dev.c41d356.0 4.1.1-dev.d41a49e.0 4.1.1-dev.ec6e117.0 4.1.1-dev.f4fd498.0 4.1.2 4.1.2-dev.054033f.0 4.1.2-dev.3ab3b39.0 4.1.2-dev.8010a6d.0 4.1.2-dev.9ad39bd.0 4.1.2-dev.a325689.0 4.1.2-dev.da3e2f5.0 4.1.2-dev.e4ba45c.0 4.1.3-dev.09f4c8b.0 4.1.3-dev.0e78235.0 4.1.3-dev.10d1f12.0 4.1.3-dev.171b413.0 4.1.3-dev.226b3ba.0 4.1.3-dev.2b445bf.0 4.1.3-dev.3060994.0 4.1.3-dev.42502b6.0 4.1.3-dev.4879326.0 4.1.3-dev.4b445ae.0 4.1.3-dev.54c5ed0.0 4.1.3-dev.66ddb7e.0 4.1.3-dev.6e43d1b.0 4.1.3-dev.70d1957.0 4.1.3-dev.80986bb.0 4.1.3-dev.80adabe.0 4.1.3-dev.90d78c1.0 4.1.3-dev.9a5fd87.0 4.1.3-dev.9b03f9d.0 4.1.3-dev.ae98628.0 4.1.3-dev.b38f00d.0 4.1.3-dev.b8fa712.0 4.1.3-dev.bfcbea8.0 4.1.3-dev.c490c18.0 4.1.3-dev.d036166.0 4.1.3-dev.e760667.0 *** 4.10.0 4.2.0 4.2.1 4.2.1-dev.6791e60.0 4.2.1-dev.7bee9bc.0 4.2.1-dev.90b8581.0 4.2.1-dev.a0d6730.0 4.2.1-dev.bd3b9a0.0 4.2.1-dev.f860b04.0 4.2.2 4.2.2-dev.116b7bb.0 4.2.2-dev.41f39c0.0 4.2.2-dev.8c643c2.0 4.2.2-dev.b05345b.0 4.2.2-dev.f6c7fca.0 4.2.2-dev.f9bcac9.0 4.2.3-dev.09c8ad0.0 4.2.3-dev.0dec262.0 4.2.3-dev.119dfa5.0 4.2.3-dev.11f20b2.0 4.2.3-dev.20cc5da.0 4.2.3-dev.2785782.0 4.2.3-dev.2c132c5.0 4.2.3-dev.2c60685.0 4.2.3-dev.332c18c.0 4.2.3-dev.3bda14d.0 4.2.3-dev.41dbf2a.0 4.2.3-dev.4778a0c.0 4.2.3-dev.6cc86b3.0 4.2.3-dev.72e9bbd.0 4.2.3-dev.7461c8e.0 4.2.3-dev.8e3e676.0 4.2.3-dev.af91519.0 4.2.3-dev.b3ccd5c.0 4.2.3-dev.b9da5a5.0 4.2.3-dev.bcd0706.0 4.2.3-dev.be86e25.0 4.2.3-dev.d8b8e18.0 4.2.3-dev.e6d8c14.0 4.2.3-dev.ef6f04e.0 4.2.3-dev.f8d8774.0 4.3.0 4.3.1-dev.0c67cc6.0 4.3.1-dev.1eb07d1.0 4.3.1-dev.23d69ba.0 4.3.1-dev.2a40b66.0 4.3.1-dev.3cfe56f.0 4.3.1-dev.43b11b8.0 4.3.1-dev.5161642.0 4.3.1-dev.59fc438.0 4.3.1-dev.5aa8b7f.0 4.3.1-dev.5afcb54.0 4.3.1-dev.65a9862.0 4.3.1-dev.6b2dbe3.0 4.3.1-dev.6c075db.0 4.3.1-dev.762c298.0 4.3.1-dev.7c33cc0.0 4.3.1-dev.80c2e1d.0 4.3.1-dev.882631c.0 4.3.1-dev.a3fe342.0 4.3.1-dev.a4f2f8c.0 4.3.1-dev.b188714.0 4.3.1-dev.b35eca1.0 4.3.1-dev.b819ee4.0 4.3.1-dev.c097b9a.0 4.3.1-dev.c858390.0 4.3.1-dev.cc7ff1f.0 4.3.1-dev.cdd99e7.0 4.3.1-dev.df594c9.0 4.3.1-dev.e1080d9.0 4.3.1-dev.e442fd2.0 4.3.1-dev.f1c6916.0 4.3.1-dev.f7d9349.0 4.3.1-dev.f9468a8.0 4.3.1-dev.fa4c72b.0 4.4.0 4.4.1-dev.028dc20.0 4.4.1-dev.0881fe1.0 4.4.1-dev.0a8f9e4.0 4.4.1-dev.42ec398.0 4.4.1-dev.6da7379.0 4.4.1-dev.727c9fc.0 4.4.1-dev.7b97011.0 4.4.1-dev.7d7a9ea.0 4.4.1-dev.95b37d8.0 4.4.1-dev.998954f.0 4.4.1-dev.9f31612.0 4.4.1-dev.a6b685e.0 4.4.1-dev.a72e99a.0 4.4.1-dev.aac2420.0 4.4.1-dev.b49094b.0 4.4.1-dev.d8b64a8.0 4.4.1-dev.e5673ca.0 4.4.1-dev.ed1460c.0 4.5.0 4.5.1-dev.040d3a3.0 4.5.1-dev.0e59f28.0 4.5.1-dev.35cb1b8.0 4.5.1-dev.86447cd.0 4.5.1-dev.8ed041c.0 4.5.1-dev.9023511.0 4.5.1-dev.95807a6.0 4.5.1-dev.9d65c38.0 4.5.1-dev.a0d4d2e.0 4.5.1-dev.a2d9cb4.0 4.5.1-dev.ab1b250.0 4.5.1-dev.afece40.0 4.5.1-dev.b25b883.0 4.5.1-dev.b4c92e1.0 4.5.1-dev.bd6cc71.0 4.5.1-dev.c5cecaf.0 4.5.1-dev.ca31f6a.0 4.5.1-dev.cf4b93f.0 4.5.1-dev.cf60f71.0 4.5.1-dev.e774646.0 4.5.1-dev.ec65468.0 4.5.1-dev.edf3164.0 4.5.1-dev.f696e47.0 4.6.0 4.6.1-dev.16a2c27.0 4.6.1-dev.1f81ff0.0 4.6.1-dev.2373e94.0 4.6.1-dev.383af39.0 4.6.1-dev.43e70c1.0 4.6.1-dev.6187f30.0 4.6.1-dev.6d0a0ae.0 4.6.1-dev.9657b86.0 4.6.1-dev.a1f9dc4.0 4.6.1-dev.a83e9d5.0 4.6.1-dev.c4e039a.0 4.6.1-dev.d254316.0 4.6.1-dev.e383ae3.0 4.6.1-dev.f943944.0 4.7.0 4.7.1-dev.1c03666.0 4.7.1-dev.526c6f5.0 4.7.1-dev.5341c3a.0 4.7.1-dev.578ebb6.0 4.7.1-dev.5a579fa.0 4.7.1-dev.67d8a74.0 4.7.1-dev.a173a8f.0 4.7.1-dev.bfb4f6f.0 4.7.1-dev.ce59737.0 4.8.0 4.8.1-dev.12c2515.0 4.8.1-dev.1ab7a6b.0 4.8.1-dev.2f73aa5.0 4.8.1-dev.32b6b29.0 4.8.1-dev.3904a46.0 4.8.1-dev.408125.0 4.8.1-dev.419c8d3.0 4.8.1-dev.53e2466.0 4.8.1-dev.553f270.0 4.8.1-dev.5d2f2aa.0 4.8.1-dev.5fd9dbb.0 4.8.1-dev.7a470c9.0 4.8.1-dev.7be0060.0 4.8.1-dev.866469d.0 4.8.1-dev.88b7e2e.0 4.8.1-dev.93296c2.0 4.8.1-dev.ac2e180.0 4.8.1-dev.b413ebd.0 4.8.1-dev.c62ef79.0 4.8.1-dev.d4e937d.0 4.8.1-dev.dd172c7.0 4.8.1-dev.de3e8f8.0 4.8.1-dev.e0fc158.0 4.8.1-dev.e29deea.0 4.8.1-dev.ebbbf1e.0 4.8.1-dev.ed2781f.0 4.8.1-dev.f216540.0 4.8.1-dev.f44dc5b.0 4.8.1-dev.f4e55bd.0 4.9.0 4.9.1-dev.22c07ad.0 4.9.1-dev.683be62.0 4.9.1-dev.692987a.0 4.9.1-dev.7084665.0 4.9.1-dev.7537f03.0 4.9.1-dev.9086b98.0 4.9.1-dev.962b99f.0 4.9.1-dev.b63af9f.0 4.9.1-dev.f687df6.0 4.9.1-dev.fd2982d.0