Created
June 19, 2022 12:43
-
-
Save Chmarusso/1238d60200be64caca965b9e31245101 to your computer and use it in GitHub Desktop.
This smart contract will automatically divide the payment amount and push it to specified recipients.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.15; | |
// SPDX-License-Identifier: MIT | |
contract PaymentSplitter { | |
address payable [] public recipients; | |
event TransferReceived(address _from, uint _amount); | |
constructor(address payable [] memory _addrs) { | |
for(uint i=0; i<_addrs.length; i++){ | |
recipients.push(_addrs[i]); | |
} | |
} | |
receive() payable external { | |
uint256 share = msg.value / recipients.length; | |
for(uint i=0; i < recipients.length; i++){ | |
recipients[i].transfer(share); | |
} | |
emit TransferReceived(msg.sender, msg.value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ipfsHash transfers the multiple account . is that possible to work this method.