Skip to content

Instantly share code, notes, and snippets.

@markpattinson
Last active August 23, 2018 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markpattinson/586327dd216d09b7fe3402eef2b29d55 to your computer and use it in GitHub Desktop.
Save markpattinson/586327dd216d09b7fe3402eef2b29d55 to your computer and use it in GitHub Desktop.
Code Line Code Description
function () public payable onlyParticipants() Defines a function only accessible to parties involved
if (msg.sender == party1) checks if it is party 1 interacting with the contract
party1EtherBalance += msg.value; adds the value of the sent funds to the stored amount
else if (msg.sender == party2) checks if it is party 2 interacting with the contract
party2TokenBalance = e.balanceOf(this); updates the token balance according to the amount present
if (party1EtherBalance >= party1PayableEther checks for satisfaction of party 1's payable funds
&& party2TokenBalance >= party2PayableTokens) checks for satisfaction of party 2's payable funds
e.transfer(party1 party2PayableTokens); transfers the payable funds to party 1
party2.transfer(party1EtherBalance); transfers the payable funds to party 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment