1

I followed https://web3js.readthedocs.io/en/1.0/getting-started.html and downloaded web3.min.js to my http host. In my html I have:

<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
    <script type="text/javascript" src="./web3.min.js"></script>
    <script type="text/javascript" src="./libs/jquery-3.2.1.min.js"></script>
    <script>
        $(document).ready(function () {
            console.log(Web3.givenProvider || web3.currentProvider);
            web3 = new Web3(Web3.givenProvider || web3.currentProvider);

            console.log('Version:', web3.version.api);
        });
    </script>
</head>
<body>
</body>
</html>

I visit the page and see version is 0.20.0. Also from the API doc, if it were 1.0 then web3.version should be 1.0 and there should be no member called .api.

What am I doing wrong here that I'm getting 0.20.0?

Chrome. Metamask 3.13.4. Downloaded web3.min.js from https://raw.githubusercontent.com/ethereum/web3.js/1.0/dist/web3.min.js

EDIT

Also tried download web3.min.js from the master branch. Same result.

EDIT

Actually for the current 1.0 I'm getting Uncaught SyntaxError: Unexpected token << from the file as I look into browser's debug window.

1

Found out what happened. The web3.min.js file downloaded from 1.0 branch was broken by a bad commit. See this particular version of the file. Apparently it was a merge commit and the author didn't merge the conflict.

I guess the web3.min.js downloaded from master branch is still 0.20.0.

I then downloaded 1.0 from a previous commit and solved the issue. Now it reads 1.0.0-beta.27.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.