I am trying to develop an dapp, but since I am running a small server (Windows Sever 2012 R2) with limited space I don't want to host/install an ethereum node, nor geth in my server, because as many of you know it takes many Gb of hard drive.
However, my "dapp" is a simple HTML page for registration. Essentially this page allows users to register and every time a registration occur; I need to designate/create a new ethereum public address with it corresponding private keys for the user. I am planning to save this information in my database (don't judge). Since I am not hosting a node in my server, I know that I need a third party to connect to mainnet in blockchain, therefore, I am using infura! I know some developer say that you can create wallets with: web3.eth.accounts.create()
but the fact is that I can use this code in node.js manually and I am able to create new wallets just fine with the following code:
var Web3 = require('web3');
var infura = "ws://mainnet.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxx";
var web3 = new Web3(Web3.givenProvider || infura);
web3.eth.accounts.create(["this is my seed phrase"]);
but when I try to implement the same approach in HTML it doesn't work. I also try keythereum.js to create wallets with the following code:
var keythereum = require("keythereum");
var dk = keythereum.create();
var readableAddress = keythereum.privateKeyToAddress(dk.privateKey);
console.log("public address:" + readableAddress);
console.log("private key in hex:" + dk.privateKey.toString('hex')
but not luck. I suspect that I may need other dependencies ir order to make it work. Can someone guide me please?
This is the code of my page!
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script src="js/web3.min.js" type="text/javascript"></script>
<script src="js/keythereum.min.js" type="text/javascript"></script>
<scrip> <!-- keythereum.js code -->
var keythereum = require("keythereum");
var dk = keythereum.create();
var readableAddress = keythereum.privateKeyToAddress(dk.privateKey);
console.log("public address:" + readableAddress);
console.log("private key in hex:" + dk.privateKey.toString('hex')
</script>
<script> <!-- web3.js code -->
var Web3 = require('web3');
var infura = "ws://mainnet.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
var web3 = new Web3(Web3.givenProvider || infura);
web3.eth.accounts.create(["this is my seed phrase"]);
</script>
</head>
<body>
<h1>Registration</h1>
</body>
</html>
Error I get:
Error: Provided address "undefined" is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can't be converted. web3.min.js:1:349717