- Lock pragma to a specific version
- Use "SPDX-License-Identifier : UNLICENSED" for non open-source code
- Import SafeMath library
- Use constructor keyword for the constructor instead of function
- "savedBalance" variable initialization is not needed.
- Use msg.sender instead of tx.origin
- The fallback function must be external and payable to be able to receive ether
- The escrow address must be payable to be able to receive ether
- It is recommended to use the function "transfer" instead of "send" because "transfer" revert if there is an exception whereas "send" return false and the execution continues.
This is the good way to do when using send:
But simply using "transfer" will revert the transaction if an error occur.
bool success; (success) = escrow.send(msg.value); require(success);
- In the "withdrawPayments" function the payee address must be declared payable.
There is a reentrance issue at instruction payee.send(payment), one way to fix the issue is to set the balance of the investor to 0 before submitting the payment
The require statements could be added in order to improve the code and save gaz in case the transaction is going to fail
savedBalance = savedBalance.sub(payment); balances[payee] = 0; payee.transfer(payment);
require(payment != 0); require(address(this).balance >= payment);
- Use PullPayment pattern for the refund.
-
Notifications
You must be signed in to change notification settings - Fork 0
davdotsol/eth-audit-smart-contract
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Audit of Blockchain Crowdsale App powered by Ethereum Smart Contracts
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published