3

Is it possible to do something like

    registry = new assetRegistry.value(1 ether)();

?

This is particularly useful when the constructor function of assetRegistry calls the ethereum alarm service, because the alarm service takes a fee

dor
  • 725
  • 1
  • 5
  • 5
  • This is definitely possible in EVM -- you can create new contract and send some ether (called endowment in this context) to it in a single instruction. I would also like to know if that is possible in solidity. – Paweł Bylica Oct 25 '16 at 21:40

1 Answers1

2

I think the Ether would be sent to address 0. But what you can do is pre-compute the address of the new contract and send the Ether first, then have the contract create the new contract. Highly advised to use testnet first, because coordination is required to make sure the correct account nonce, which would have to be provided from the outside.

eth
  • 85,679
  • 53
  • 285
  • 406
  • Is there any way to get an account's nonce from inside a contract? – Nick Johnson May 28 '16 at 09:41
  • No, I was going to suggest it does need "outside" help to get the nonce... – eth May 28 '16 at 09:43
  • 1
    Of course, you could code the contract to keep track of how many other contracts it's created, effectively keeping a duplicate nonce... – Nick Johnson May 28 '16 at 09:47
  • assuming a contract keeps track of its nonce, is there a solidity word for rlp_encode ? or a library ? example address precomputedRegContract = sha3(rpl_encode(this, nonce)); – dor May 29 '16 at 04:36
  • https://github.com/androlo/standard-contracts#rlp might help – eth May 29 '16 at 04:52