3

I've managed to deploy a contract on geth by unlocking the account of the node. (How this would work in production I have no idea, as I think it would pose a security risk)

Now I connect with my truffle app to the local geth node (connecting my truffle app to the testrpc works completely, with callbacks etc.)

What I'm missing is the 10 accounts & 10 private keys that I get with testrpc on my geth account.

Correct me if I'm wrong, but I could add these in my genesis.json, but they are different each time I start the testrpc, but the same when I start geth.

What I'm missing, or can't see any clear instructions or workflow for, is switching between the two.

Where would I start when I want to test it on a geth (or other eth node) instance?

Main issues:

  • I can't influence the accounts being used/created with testrpc, only the number of default accounts.
  • When I successfully deploy contracts and compile .sol.js files and the addresses match the ones registered in the geth instance, I do a transfer, but the promise callback (then) doesn't get triggered, whereas on the testrpc it does.

The callback in question:

    shares.sendShares(destinationAccountId, amount, {from: accountId}).then(function() {

       return getShares(accountId, function(val){
         store.dispatch(setSendStatus("Shares Sent!", val))
       })      

       return getDestinationShares(destinationAccountId, function(val){
         store.dispatch(setDestinationStatus("Shares received!", val))
       });

  })
  • Right now, I'm just retrieving the accounts array and use the 0 and 1 of that, what if I want a default existing account integrated in testrpc?

Not sure how relevant, but my genesis.json: (from: http://tech.lab.carl.pro/kb/ethereum/testnet_setup)

  {
    "nonce": "0x0000000000000042", 
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", 
    "difficulty": "0x4000", 
    "alloc": {},
    "coinbase": "0x0000000000000000000000000000000000000000", 
    "timestamp": "0x00", 
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 
    "extraData": "Custem Ethereum Genesis Block", 
    "gasLimit": "0xffffffff"
  }
  • "Now I connect with my truffle app to the local geth node (which works with testrpc)" I don't understand this. Testrpc is a js ethereum simulator that provides an rpc provider and simulates a blockchain. Geth is actually a real ethereum client -but can be used with a private testnet providing the proper flags-. I don't get it when you say that your geth node works with your testprc. When you deploy your pudding contract, what do you set as your rpc provider? – Sergeon Jul 12 '16 at 12:15
  • @Sergeon, sorry, it was confusing phrasing. I phrased it differently now. – BlockChange Jul 12 '16 at 12:20
  • You actually are able to unlock and use fake accounts in your geth test enviroment? Or your problem is you can't get those to work? – Sergeon Jul 12 '16 at 12:32
  • @Sergeon, I'm now just making 2 accounts on the local geth, and referring to the containing array with accounts[0] etc. But this is not practical in a live environment, where there are dozens of accounts, which can be shuffled around depending how they alphabetically sort (or whatever sorting algorythm is used) – BlockChange Jul 12 '16 at 12:40
  • I see. Don't have much experience with geth testnets, I only have experience with testrpc. If I did understand this well, I think you should make two separate questions: one ragarding how to manage geth accounts properly an another about your failing promise, providing more background and code. GL! – Sergeon Jul 12 '16 at 12:43
2

I've managed to deploy a contract on geth by unlocking the account of the node. (How this would work in production I have no idea, as I think it would pose a security risk)

I'm assuming you've used the console to unlock the account and not a scripted approach through JSON-RPC (which can be easily invoked from web request command line tools or browsers).

In production one would most likely use a secure network (with rigorous firewall rules, etc.) and run sensitive operations (which expose the private keys used to sign transactions) within there and synchronize with external peers.

It is also possible to write an SSL wrappers over current client implementations so that accessing client endpoints requires mutual authentication. This way the host running the Ethereum client can control who is connecting to it.

Now I connect with my truffle app to the local geth node (connecting my truffle app to the testrpc works completely, with callbacks etc.)

What I'm missing is the 10 accounts & 10 private keys that I get with testrpc on my geth account.

Correct me if I'm wrong, but I could add these in my genesis.json, but they are different each time I start the testrpc, but the same when I start geth

You can assign balances to addresses in the genesis block (see the alloc key) but make sure you store the private keys used to generate those addresses as they are required if you later want to make use of the balance.

Regarding testrpc, there is an example usage here that shows how to assign balances to accounts.

Main issues:

I can't influence the accounts being used/created with testrpc, only the number of default accounts.

See the above link/other answer.

When I successfully deploy contracts and compile .sol.js files and the addresses match the ones registered in the geth instance, I do a transfer, but the promise callback (then) doesn't get triggered, whereas on the testrpc it does.

What do you mean registered in he geth instance? Created accounts using geth? If so you might be using different accounts for geth and testrpc.

  • 1
    Thanks, as for the last one, I messed up by putting return in front of the async methods in an attempt to fix the annoying bluebird warning (nothing returned from promise), but this broke the callbacks, and I hadn't noticed when I decided to test on geth – BlockChange Jul 14 '16 at 14:02
3

You can influence the accounts:

$ testrpc --account="<privatekey>,balance" [--account="<privatekey>,balance"]

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.