[Ethereum] Solidity Smart Contract auto withdrawal (ETH)

cpp-ethereumminingmining-poolssolidity

I'm kinda new to smart contracts, searched a lot, but hope someone here can help me out.

I'll try to explain as good as I can. I'm mining Ethereum with a couple of rigs.

Each individual rig auto-sends the ETH to a specific ETH address via pool. So now I have multiple (30+) ETH addresses that are receiving ETH. Very frustrating to check every address and send the ETH to my main account by hand.

Is there a way that I can auto-send ETH from each account to my MAIN account with a smart contract (solidity)?

Let's say; Address 1 receives 0.1 ETH, auto send (immediately after transaction comes in) 0.1 ETH to MAIN ETH address.

The addresses are receiving different amounts of ETH, some 0.1 ETH some 0.05 ETH, etc. No matter what amount is send to the mining address, it must be transferred to the main account.

I hope someone can help me out with this.

Edit: Example

0x0000ADRESS1: 0.1ETH

0x0000ADRESS2: 0.3ETH

0x0000ADRESS3: 0.2ETH

0x0000ADRESS4: 0.1ETH

(Write an smart contract for each address above, when ETH is in above addresses, transfer ETH to MAIN)

0x0000MAINADRESS: 0.7ETH

Best Answer

it doesn't work quite like you seem to think and that makes it sort of challenging to answer directly with some advice that won't lead to long learning curve.

In Ethereum, you have externally owned accounts (EOA) (wallets) and contracts, both of which are represented by addresses and are barely distinguishable in the smart contract language. Nothing ever happens on the chain unless someone signs a transaction from an EOA. Contracts run code when they receive a message.

In particular, no EOA or contract can spend money from someone else's account. Contracts receive money and send it just like a wallet. So, we can't really make a contract that sucks the money out of the addresses. We could, conversely, deploy contracts under the control of the various accounts and the various accounts could sign transactions to kick things off, but how would that address your goal? See the issue?

Your goal can be achieved with a reasonably simple Hub and Spoke design with the Pool payments going to contracts that are Spokes. Spokes forward all funds received to a Hub. Hub lets a privileged user (you) withdraw funds, and Hub let's you generate new Spokes, inspect the list of spokes, and so on.

I feel that example code might just be leading you into a project of unexpected complexity because you would have to get accustomed to something a little foreign compared to how things work presently.

Hope it helps.

Related Topic