3

I'm trying to create an initialization script for testrpc that creates specific accounts with specific balances at start up.

testrpc  --debug -account="aa73b5c98e60d589e71ce7cff59c02f82e12c7ce676ee356da8e058a285ccd61,100000"

generates the following

testrpc  --debug --account="aa73b5c98e60d589e71ce7cff59c02f82e12c7ce676ee356da8e058a285ccd61,100000"
/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/solc/soljson.js:1
(function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["readFileS

RangeError: private key length is invalid
    at RangeError (native)
    at Object.exports.privateToPublic (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-util/index.js:356:20)
    at StateManager.createAccount (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/statemanager.js:155:25)
    at Array.map (native)
    at StateManager.initialize (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/statemanager.js:71:33)
    at new GethApiDouble (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/subproviders/geth_api_double.js:21:14)
    at Object.Interface.provider (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/interface.js:148:25)
    at Object.Interface.server (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/interface.js:29:25)
    at Object.TestRPC.server (/usr/local/lib/node_modules/ethereumjs-testrpc/index.js:5:22)
    at Object

The private key I'm using was generated in the previous run of testrpc as a test account:

Available Accounts

(0) 0x22ddfe3c6439839edf8e2e56126c65c5fc5a2f40 (1) 0xc1da5556ecfc0ac4168d60bc8c884ae3dd6fba3f (2) 0xb234a0c1afbd20e1f9a117272136aeaafaccb614 (3) 0xc8c206e296e92a475ee4c2bf9fb8d00d7ac83876 (4) 0x8b22109f827a7d6b16b085f9755e23a124a21709 (5) 0x34cb6cc7cc29f6ce978521ad691716fd7a3809c8 (6) 0xa3b692025e76530506a232188b6ecd681027585e (7) 0x9b5a29122e80f8975d50a031b21e88adae489cf4 (8) 0xa921ef355a7d2729e7674a081aeeceff28419e23 (9) 0x444a798fad3ef318bfd7cee26c5937298cc2cbec

Private Keys

(0) aa73b5c98e60d589e71ce7cff59c02f82e12c7ce676ee356da8e058a285ccd61 (1) 2337bf7968f70bcc7b1c04aba780b6157c3db9c575481c19e90f347f50c5df95 (2) 8d5cd323b43ee0fe3c3073bbbfa174d682ac8564164b2f253111ee591323a4f4 (3) fccb97187708748a88c7dd7419c63fa3f5c125826116827f5459c72c2a07cd2a (4) 032b517d15b77d0e8d8611beeb3e43021637c37fc4a6efcc40e6fa2fe0e20850 (5) d5af034aa8990068eee4581012a4010fb78220293464ac3e39ca40f9cb79a873 (6) 9767f461cc6a1a0688e570846618547de95955d2bfeb37746c6997b7257e156e (7) dc6a7f0cd30f86da5e55ca7b62ac1a86f5d8b76a796176152803e0fcbc253900 (8) 52f3a1fa15405e1d5a68d7774ca45c7a3c7373a66c3c44db94a7f99a22c14d28

I have also tried to use a HEX balance instead of an integer and got the same result.

  • What is the question? – niksmac Feb 1 '17 at 4:42
4

Per the testrpc Readme you need a 0x stuck on the front of the private key.

2
testrpc  --debug -account="0xaa73b5c98e60d589e71ce7cff59c02f82e12c7ce676ee356da8e058a285ccd61,100000"

add 0x prefix

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.