0

I have low cost hosting and I cannot install node etc. I have basically just rights to use html and run javascript. Can we use web3 on that basis or do I need a server side installation of node or something like that?

I tried using -

const Web3 = require('web3');

and I get not defined because I have no node installed I think.

1

web3 can be used either on client side or in NodeJS. You are getting undefined because if you use that kind of syntax in your client application you need to use something like webpack to build your bundle for the browser.

Anyway, another option can be to include web3 inside your front-end downloading it from here. So you can just include it in your HTML

<script type="text/javascript" src="path/to/web3.min.js"></script>
0

Another solution would be using Metamask on the client-side. They would do all the heavy lifting and provide you with all the functionality that you need.

To download: https://metamask.io/

Guide: https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md

Another option you could use is directly as a browser module CNN: https://github.com/ethereum/web3.js/#as-browser-module

<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js/dist/web3.min.js"></script>

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.