@jesus666 I'm getting the following error when using curl: {"id":-1,"jsonrpc":"2.0","error":{"code":-32600,"message":"Could not decode request"}} Any idea how to get the address returned and get rid of this error?
Hi! I've tried this method with the following script trying to see if it escalates well (using nodejs):
var rpc = require('json-rpc2'); var client = rpc.Client.$create(8545, "localhost"); for (I=0; I < 10; I++) client.call("personal_newAccount", ["password"], function(err,result){ console.log(result); });
With I < 10 it works but my first attempt of 10000 was a nice geth crash yielding for more file descriptors. However later trying more realistic values, I got that above 30 I get no accounts and the system load skyrockets to the max.
So I think that this is an option for sporadic account creation, but not for a service or sas with some load.
Any other suggestion or alternative for creating ethereum accounts programatically?
Comments
You can, however, do it by calling JSON-RPC directly. The RPC method you're looking for is "personal_newAccount". You request would look like:
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_newAccount","params":["pass"],"id":74}' http://localhost:8545
Replace "pass" with an actual password.
Keep in mind, you must run geth with the "personal" api enabled to make this method available:
geth --rpc --rpcapi "personal,eth,web3"
. More on RPC/IPC APIs here: https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console#management-apisAlternatively, you can use the JS Console provided by Geth: https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console#personalnewaccount
var rpc = require('json-rpc2');
var client = rpc.Client.$create(8545, "localhost");
for (I=0; I < 10; I++) client.call("personal_newAccount", ["password"], function(err,result){ console.log(result); });
With I < 10 it works but my first attempt of 10000 was a nice geth crash yielding for more file descriptors. However later trying more realistic values, I got that above 30 I get no accounts and the system load skyrockets to the max.
So I think that this is an option for sporadic account creation, but not for a service or sas with some load.
Any other suggestion or alternative for creating ethereum accounts programatically?
Thanks in advance.