2

Is it possible to deploy contracts from within contracts, using something like p.recipient.call.value(p.amount * 1 ether)(bytecode);

This article says so, https://blog.ethereum.org/2015/12/04/ethereum-in-practice-part-2-how-to-build-a-better-democracy-in-under-a-100-lines-of-code/

Can it get any better than this? Actually, it can. On our next post we will explore how you can use “transactionBytecode” to allow the DAO to execute any kind of ethereum transaction, even owning or creating other contracts.

But when I try create a contract by sending the bytecode without an address field, the transaction is sent to 0x0000000000000000000000000000000000000000 but no contract is created.

UPDATE:

Show us your code! We can't usefully help if we can't see what you're trying. – Nick Johnson

In the ethereum.org/dao framework, doing new proposal,

bytes32 transactionBytecode =  0x606060405260068060106000396000f3606060405200

newProposal(transactionBytecode)

to create contract

contract MyContract {
    /* Constructor */
    function MyContract() {

    }
}

The bytecode should create a new contract, but no contract is created. If I do the same transaction from a human account, it deploys a contract.

  • Show us your code! We can't usefully help if we can't see what you're trying. – Nick Johnson May 25 '16 at 9:22
  • added some code :) I was thinking that maybe the ethereum.org/dao framework doesn't support creating contracts through proposals, and so I guess the question is: can contracts deploy new contracts by using the .call opcode ? that is what ethereum.org/dao uses, p.recipient.call.value(p.amount * 1 ether)(bytecode); – dor May 25 '16 at 10:42
  • Yes, they can. That can't be call the code you're executing, though! Where is the snippet above executed? Where did transactionBytecode come from? – Nick Johnson May 25 '16 at 10:56
  • I copied bytecode from a human-account transaction that successfully created a contract, and then put it as transactionBytecode in a proposal, and left beneficiary empty, and exectued to proposal which sent it with the .call command to 0x0000000000000000000000000000000000000000 But I see no new contract. When I sent the same bytecode from a human account and left the toaddress empty, it creates a contract. – dor May 25 '16 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.