Total Prize Pool: $40,000
Starts July 24, 2023
Ends August 5th, 2023
nSLOC: ~182
Complexity Score: ~106
This project is meant to enable smart contract auditors (sellers) and smart contract protocols looking for audits (buyers) to connect using a credibly neutral option, with optional arbitration.
Actors
arbiterFee
amount if a dispute occurs.Escrow
contract given that it enables a malicious buyer to DOS Escrow::resolveDispute
EscrowFactory::newEscrow
, given that the caller of this contract is in control of the salt, frontrunning is a possibility.
Create an Escrow
EscrowFactory
.EscrowFactory::newEscrow
, inputs:
create2
Escrow
deployment.Expected sucessful workflow
Escrow
contract through EscrowFactory::newEscrow
, depositing the funds.Escrow::confirmReceipt
. This sends the funds to the seller. Expected dispute workflow
Escrow
contract through EscrowFactory::newEscrow
, depositing the funds.Escrow::initiateDispute
.Escrow::resolveDispute
, reimbursing either side accordingly, emptying the Escrow
.All contracts in src
are in scope.
Note on script
folder:
The contracts in script
are the scripts you can assume are going to be used to deploy and interact with the contracts. If they have an issue that will affect the overall security of the system, they are in scope. However, if they have a security issue that only affects the script and not the overall deployment of the escrow protocol, it is out of scope.
buyer
deploys a new Escrow
, the buyer
and seller
should agree to the terms for the Escrow
. If the buyer
accidentally or maliciously deploys an Escrow
with incorrect arbiter
details, then the seller
could refuse to provide their services. Given that the buyer
is the actor deploying the new Escrow
and locking the funds, it's in their best interest to deploy this correctly.seller
payment - In this scenario, the seller
can decide to not perform the audit. If this is the case, the only way the buyer
can receive any of their funds back is by initiating the dispute process, in which the buyer
loses a large portion of their deposited funds to the arbiter
. Therefore, the buyer
is disincentivized to deploy a new Escrow
in such a way.buyer
never calls confirmReceipt
- The terms of the Escrow
are agreed upon by the buyer
and seller
before deploying it. The onus is on the seller
to perform due diligence on the buyer
and their off-chain identity/reputation before deciding to supply the buyer
with their services.salt
input when creating an Escrow
can be front-runarbiter
is a trusted rolebuyer
calling confirmReceipt
too soontokenAddress
funds lockedgit --version
and you see a response like git version x.x.x
forge --version
and you see a response like forge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)
git clone https://github.com/Cyfrin/2023-07-escrow
cd escrow
forge build
forge test
forge coverage
and for coverage based testing:
forge coverage --report debug
make anvil
This will default to your local node. You need to have it running in another terminal in order for it to deploy.
make deploy
You'll want to set your SEPOLIA_RPC_URL
and PRIVATE_KEY
as environment variables. You can add them to a .env
file, similar to what you see in .env.example
.
PRIVATE_KEY
: The private key of your account (like from metamask). NOTE: FOR DEVELOPMENT, PLEASE USE A KEY THAT DOESN'T HAVE ANY REAL FUNDS ASSOCIATED WITH IT.
SEPOLIA_RPC_URL
: This is url of the goerli testnet node you're working with. You can get setup with one for free from AlchemyOptionally, add your ETHERSCAN_API_KEY
if you want to verify your contract on Etherscan.
Head over to faucets.chain.link and get some tesnet ETH. You should see the ETH show up in your metamask.
make deploy ARGS="--network sepolia"
You can estimate how much gas things cost by running:
forge snapshot
And you'll see and output file called .gas-snapshot
To run code formatting:
forge fmt