1

I am trying to figure out if this pattern for an ethereum smart contract would be possible or are there limitations in solidity or the evm which would prevent this.

Contract A is deployed on the blockchain with address 0xA, within contract A's code there is a function such that if ethereum is received above a threshold it will create another contract (say Contract Child, say at 0xB). So the contract has to respond to the event where an address sends it ether. Within Contract Child's code there are certain functions that do the following:

  1. Allow it to accept ether (from other third parties, say address 0xC) and return that ether at a future date automatically.

For this pattern, I was curious to know if

  1. Will each instance of Contract Child have its own address, accesible to the outside addresses. I know that a contract creating an instance of another contract would be an internal txn, but does this Contract Child have it's own address I can send txns to? Or do I have to access the original contract's internal storage to find those contracts. If yes, are there any special ways to access given it is not a contract with a blockchain address?
  2. If there are addresses where each instance of Contract child is created, I assume I can log them into an array of addresses an access them as such. Would this be correct?
  3. I assume the last part, the Contract receiving transactions, specifically ether transfers and then sending them back to the address which sent them would not cause any difficulty in solidity or the EVM.

I am fairly new to smart contract development so apologies if I am stating something a bit off.

1 Answer 1

0

It is possible to have a smart contract deploy other contracts as you describe here and each deployment will consist on a new contract (and contract address) on the blockchain. You would be able to send transactions directly to this "child" contract without going through the deployer contract.

For your second question, yes, the command used to deploy new contracts will return an address (the address of deployed contract) which you can be stored in a variable in your deployer contract.

For your last question, it is possible to have these type of contracts where users can send any amount of ETH, have the coins locked for a period of time, then be withdraw-able after this time. Do note that smart contract are not self-executing so it is not possible to schedule contract code to run at a certain point of time in the future. Contracts need to be called via transactions to have their logic executed in a given block.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.