đ This smart contract in Solidity is called SplitPay. It allows payments to be split between several members. Each member must make a minimum deposit specified when the contract is created. đ° When a member submits a payment, their address is recorded, and the amount is added to the total balance. Members can then use this balance to pay bills by entering the beneficiary's address and the amount to be paid. The balance is deducted from the amount paid and transferred to the beneficiary. đ¸
// SPDX-License-Identifier: MITpragmasolidity ^0.8.18;contract SplitPay {uintpublic minDeposit;uintpublic balance;address [] members;mapping (address=>bool) paid;eventSubmit(addressindexed sender,uint amount,uint timestamp );eventPayInvoice(addressindexed receiver,uint amount,uint timestamp );constructor(uint_minDeposit) {require(_minDeposit>=1); minDeposit = _minDeposit *1ether; }functiongetContractBalance() externalviewreturns (uint) {returnaddress(this).balance; }functiongetMembers() externalviewreturns (address[] memory) {return members; }functionsubmit() externalpayable {address _sender = msg.sender;uint _amount = msg.value;require(!paid[_sender],"You have already submitted a payment.");require(_amount>=minDeposit,"The submitted amount is less than the minimum required deposit."); members.push(_sender); paid[_sender]=true; balance+=_amount;emitSubmit(_sender,_amount,block.timestamp); }functionpayInvoice(address_receiver,uint_amount) external { require( _amount<=balance,"The invoice amount exceeds the available balance." );require( paid[msg.sender],"You are not authorized to pay the invoice" ); _amount *=1ether; balance -=_amount; (bool success,) = _receiver.call{ value: _amount }("");require(success,"Payment of the invoice failed.");emitPayInvoice(_receiver, _amount, block.timestamp); }}