In other words, can a contract initiate a transaction by itself, without someone activating it's code? An example would be if a contract can do that
when times eg. reaches a specific point.
-
If you are able to get a private key that generates the same address than a contract then this will apply ethereum.stackexchange.com/questions/217/….– Ismael ♦Commented Dec 8, 2021 at 19:52
1 Answer
In other words, can a contract initiate a transaction by itself, without someone activating his code?
No.
Smart contracts are not autonomous, their behavior is triggered by signed public transactions broadcast on the network by Externally Owned Accounts (EOA), basically an entity holding a private key. To 'initiate' (i.e., send) a transaction you need a private key, and autonomy. Smart contract cannot keep a private key private since they are stored on the public blockchain, therefore they can only be reactive in the current form of Ethereum and blockchain more generally.
tx.origin
cannot be a smart contract by definition.
To automate smart contract behaviors several services already exist, the most famous one is arguably Chainlink keepers. It basically sends a transaction from an EOA when required.