When we have a contract, we transfer currency
How is the signature done ???
For example, I send 10 ethers to the contract and the contract is divided between 5 people
What is this transaction like? Where does my private key come from to sign all 5 transactions?
I send 10 ethers to the contract and the contract is divided between 5 people
So possibly something like this:
pragma solidity ^0.8;
contract MyContract {
function redistribute(address[5] memory otherPeople) external payable {
for(uint i = 0; i < 5; i++) {
payable(otherPeople[i]).transfer(msg.value / 5);
}
}
}
You send one transaction (valued 10 ETH) to the contract, executing the redistribute()
function.
The contract performs 5 internal transactions, effectively transferring 2 ETH to each of the otherPeople
addresses.
In this case, you only need to use the private key of the "main" transaction sender, because the other transactions are internal txs, wrapped by the main tx.