Self replicating contract

Will it be possible for a contract to replicate itself?

Why would you want this you ask? Consider the following example:

A notary contract
- Stores hashes of documents in the contract storage.
- A contract plugin will allow you to open a document and verify if (and if so when) the has of the document has been stored in the Etherum blockchain.
- When the contract storage is almost full, the contract uses parts of the received ether to open a new contract, so it has new storage available.
- It will notify a 'tracker' contract of it's new location by sending a transaction with a small amount of either to the tracker contract, which stores the senders address in address storage.

An alternative would be to store the hashes off-blockchain, and just use the contract for the payment and verification (in the same way as the dropbox alternative example in the whitepaper).


  • yoyoyoyo Member Posts: 34 ✭✭✭
    edited February 2014
    Make a loop reading the first storage slots of permanent storage where the code is stored, send that to the empty address. Voilà, self replicating contract replicating itself until there is no ethers left to create the next generation.
    The only problem I see is for the Nonce. We will need to have pseudorandom number generators seeded with the contract address or something.
  • VitalikButerinVitalikButerin Administrator Posts: 84 admin
    edited February 2014
    if[9999] == 0:[9999] = 1 x = array() x[0] = contract.address mktx(TRACKER,10^18,x,1) [ main code ] if copyme: data = array() i = 0 while[i] > 0: data[i] =[i] mktx(0,10^18,data,i)

    Also, the nonce isn't an issue; transactions created inside scripting code don't need a nonce. And nonces are meant to be incremental, not pseudorandom anyway.
Sign In or Register to comment.