Skip to content

Commit 2c5b5d2

Browse files
committed
make it better
1 parent 5bc822b commit 2c5b5d2

File tree

8 files changed

+20
-16
lines changed

8 files changed

+20
-16
lines changed

avoiding_common_attacks.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
1) Using Specific Compiler Pragma: SWC-103
2-
using pragma solidity ^0.8.3;
1+
# Contract security measures
32

4-
2) Proper Use of Require and Revert: SWC-123
5-
using Require in SwapTokens Contract to check ETH and tokens balance before any transfer and Revert to revert back ETH of invalid txns.
3+
1) Floating Pragma: SWC-103
4+
Using specific compiler pragma 0.8.3 in contracts to avoid accidental bug inclusion through outdated compiler versions.
5+
6+
7+
2) Requirement Violation: SWC-123
8+
Using Require in SwapTokens Contract to check ETH and tokens balance before any transfer and using Revert to revert back ETH of invalid txns.

contracts/Migrations.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity ^0.8.3;
2+
pragma solidity 0.8.3;
33

44
contract Migrations {
55
address public owner;

contracts/SwapTokens.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity ^0.8.3;
2+
pragma solidity 0.8.3;
33

44

55
// Using dependency-injection to call other contracts' functions.

contracts/TokenA.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity ^0.8.3;
2+
pragma solidity 0.8.3;
33

44
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
55

contracts/TokenB.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity ^0.8.3;
2+
pragma solidity 0.8.3;
33

44
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
55

deployed_address.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Testnet: Rinkeby
2-
SwapTokens Contract Address: 0xF2e6d2CdF5749e20aE15F48E4070bc584C8D7F69
3-
TokenA Contract Address: 0x8FBdB5Da8a38D5c799Ad353c53F5C0744c5F6E0B
4-
TokenB Contract Address: 0xD6697E4fF3c5c1aeb6f30DB712c8981ACbCDCbBe
5-
Migrations Contract Address: 0x24F6b3921B4Ae67f6266f886E5B0c4bdAA0fF3AD
2+
SwapTokens Contract Address: 0x2522B1aAeA8a12cFe82E65CF7B07cc61eFD893DC
3+
TokenA Contract Address: 0xb6409B711d511A7db64cCBDa2Eca452AAad58ee2
4+
TokenB Contract Address: 0x817E0B7b325Dd3b4EC40bF5895d4f51b01800Da1
5+
Migrations Contract Address: 0x233937ADdE8e3B644fc41AEFEd9ccc1609f9E7A3
66
Deployer Public Address: 0x4bb52fF3e053d127265A8A8dDf9Dc291fcF04aF0
7-
Final cost: 0.009676172557372237 ETH
7+
Final cost: 0.00967614254761444 ETH

design_pattern_decisions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
# Design patterns used:
2+
13
1)Inter-Contract Execution:
24
SwapTokens Contract calls TokenA and TokenB functions by importing them (aka dependency injection).
35

46

57
2) Inheritance and Interfaces:
68
TokenA and TokenB contracts are ERC20 tokens, they inherit from @openzeppelin/contracts/token/ERC20/ERC20.sol contract.
79

8-
3) Access Control Design Patterns:
9-
SwapTokens contract uses Ownable access control.
1010

truffle-config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ module.exports = {
2222
return new HDWalletProvider(MNEMONIC, API_URL)
2323
},
2424
network_id: 4,
25-
gas: 4000000 //4M is the max
25+
gas: 4000000, //4M is the max
26+
2627
}
2728

2829
},

0 commit comments

Comments
 (0)