This is my first smart contract that I have tried to build. Got some of this code from another forum (here) Solidity Smart Contract - Split and Send Contract ETH Balance Between Two Accounts.
I am trying to modify it to fit my needs. Essentially, I want a contract that splits earnings to two accounts equally. I was hoping to have the funds send automatically, however the first account (receiving funds from OpenSea) will likely have to manually send funds to smart contract address.
Either way, I thought this code would be nearly complete but I get this error:
TypeError: Type address is not implicitly convertible to expected type address payable.
Is this a new version thing that I am not catching?
Any help is appreciated, thank you.
Also if anyone has any tips on how I can make this contract automatically send funds to two accounts every time another account receives funds, I would really appreciate it.
My code so far:
pragma solidity ^0.8.9;
contract JointEarnings {
address payable account_one = 0x825Ecf093bcC4de26baf8116B74255ADC9b870C5;
address payable account_two = 0xD86Df7757176B75bDFE5783c0E40c0d05eBf7eB7;
uint public balanceContract;
function distribute(uint amount, address payable recipient) public {
recipient.transfer(amount);
balanceContract = address(this).balance;
}
function distribute_equal() public {
uint amount = balanceContract / 2;
account_one.transfer(amount);
account_two.transfer(amount);
balanceContract = address(this).balance;
}
function deposit() public payable {
balanceContract = address(this).balance;
}
function recieve() external payable {}
}