Distribute escrow funds

I’m trying to build this escrow contract that will hold the funds from a transaction until both the buyer and the seller have accepted the release. Additionally, if the either one of them does not accept the funds will be withheld by the smart contract for a duration of 30 days. How can I add the address that initially deployed the smart and transfer 3% of the total deposit to that address if the transaction was successful ?

Also being relatively new to this, can multiple pairs of users interact with the contract at the same time and benefit from the escrow (will it instantiate a new version for every pair) ?

This is what I have tried for now


pragma solidity 0.7.0;

contract NewEscrow {

enum State {AWAITING_FUNDS,AWAITING_CLAIM,CLAIM,COMPLETE}

State public currentState; 


address payable public buyer; 
address payable public seller; 
address payable public owner; 

uint256 public agreementDay; 

mapping (address => uint256) deposits;




// checks if msg.sender is equal to buyer
modifier onlyBuyer (){
    require(msg.sender == buyer);
    _; 
}


// checks if msg.sender is equal to seller
modifier onlySeller(){
    require(msg.sender == seller);
    _; 
}


constructor (){
    owner = msg.sender; 
}


function setVariables (address payable _buyer, address payable _seller, uint256 _agreementDay) public {
    buyer = _buyer; 
    seller = _seller; 
    agreementDay = _agreementDay + 30 days; 
    currentState = State.AWAITING_FUNDS;
}



function deposit() public onlyBuyer payable {
    require(currentState == State.AWAITING_FUNDS);
    uint256 amount = msg.value;
    deposits[seller] = deposits[seller] + amount; 
    currentState = State.AWAITING_CLAIM;
}


function claim () public onlySeller {
    require(currentState == State.AWAITING_CLAIM);
    currentState = State.CLAIM;
}


function confirm () public onlyBuyer {
    uint256 payment = deposits[seller];
    deposits[seller] = 0; 
    seller.transfer(payment); 
    currentState = State.COMPLETE;
}



function cancelPayement () public onlySeller  {
    uint256 payment = deposits[seller];
    deposits[seller] = 0; 
    buyer.transfer(payment); 
    currentState = State.COMPLETE;
}


function release() public{
    
    
        // funds cannot be retrieved before release day
        require (agreementDay < block.timestamp);
        uint256 payment = deposits[seller];
        deposits[seller] = 0; 
        buyer.transfer(payment);
        revert('funds returned');
    }
}

Please make sure to actually read the Welcome Message of the forum before posting (this post does not belong in the AMA category). :slight_smile: If you want to get feedback from other Solidity devs, consider moving this post to the “Code Wizards” category, or use the Solidity Gitter/Matrix chat.