diff --git a/README.md b/README.md index 4566831..46422da 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,9 @@ To get started with EasyPay, follow the steps below: -1. Clone this repo & install dependencies +1. Make sure you have the [foundry toolkit installed](https://book.getfoundry.sh/getting-started/installation). + +2. Clone this repo & install dependencies ``` git clone https://github.com/luloxi/EasyPay.git @@ -19,7 +21,7 @@ cd EasyPay yarn install ``` -2. Run a local network in the first terminal: +3. Run a local network in the first terminal: ``` yarn chain @@ -27,7 +29,7 @@ yarn chain This command starts a local Ethereum network using Hardhat. The network runs on your local machine and can be used for testing and development. You can customize the network configuration in `hardhat.config.ts`. -3. On a second terminal, deploy the test contract: +4. On a second terminal, deploy the test contract: ``` yarn deploy @@ -35,7 +37,7 @@ yarn deploy This command deploys a test smart contract to the local network. The contract is located in `packages/hardhat/contracts` and can be modified to suit your needs. The `yarn deploy` command uses the deploy script located in `packages/hardhat/deploy` to deploy the contract to the network. You can also customize the deploy script. -4. On a third terminal, start your NextJS app: +5. On a third terminal, start your NextJS app: ``` yarn start @@ -63,16 +65,26 @@ Run smart contract test with `yarn hardhat:test` ## Contents -- [Requirements](#requirements) -- [Quickstart](#quickstart) -- [Deploying your Smart Contracts to a Live Network](#deploying-your-smart-contracts-to-a-live-network) -- [Deploying your NextJS App](#deploying-your-nextjs-app) -- [Interacting with your Smart Contracts: SE-2 Custom Hooks](#interacting-with-your-smart-contracts-se-2-custom-hooks) -- [Disabling Type & Linting Error Checks](#disabling-type-and-linting-error-checks) - - [Disabling commit checks](#disabling-commit-checks) - - [Deploying to Vercel without any checks](#deploying-to-vercel-without-any-checks) - - [Disabling Github Workflow](#disabling-github-workflow) -- [Contributing to Scaffold-ETH 2](#contributing-to-scaffold-eth-2) +- [💸 EasyPay 💸](#-easypay-) + - [Quickstart](#quickstart) + - [🏗 About Scaffold-ETH 2](#-about-scaffold-eth-2) + - [Contents](#contents) + - [Requirements](#requirements) + - [Quickstart](#quickstart-1) + - [Deploying your Smart Contracts to a Live Network](#deploying-your-smart-contracts-to-a-live-network) + - [Deploying your NextJS App](#deploying-your-nextjs-app) + - [Interacting with your Smart Contracts: SE-2 Custom Hooks](#interacting-with-your-smart-contracts-se-2-custom-hooks) + - [useScaffoldContractRead:](#usescaffoldcontractread) + - [useScaffoldContractWrite:](#usescaffoldcontractwrite) + - [useScaffoldEventSubscriber:](#usescaffoldeventsubscriber) + - [useScaffoldEventHistory:](#usescaffoldeventhistory) + - [useDeployedContractInfo:](#usedeployedcontractinfo) + - [useScaffoldContract:](#usescaffoldcontract) + - [Disabling type and linting error checks](#disabling-type-and-linting-error-checks) + - [Disabling commit checks](#disabling-commit-checks) + - [Deploying to Vercel without any checks](#deploying-to-vercel-without-any-checks) + - [Disabling Github Workflow](#disabling-github-workflow) + - [Contributing to Scaffold-ETH 2](#contributing-to-scaffold-eth-2) ## Requirements diff --git a/packages/foundry/contracts/EasyPay.sol b/packages/foundry/contracts/EasyPay.sol index 70a6f0e..e2a37b6 100644 --- a/packages/foundry/contracts/EasyPay.sol +++ b/packages/foundry/contracts/EasyPay.sol @@ -13,7 +13,7 @@ struct PayRequest { bool completed; } -contract Easy2Pay { +contract EasyPay { address public owner; uint256 requests; @@ -23,17 +23,17 @@ contract Easy2Pay { mapping(uint256 requestId => PayRequest) public payRequests; // Custom errors - error Easy2Pay__RequestDoesNotExist(); - error Easy2Pay__InsufficientEther( + error EasyPay__RequestDoesNotExist(); + error EasyPay__InsufficientEther( uint256 requestedAmount, uint256 actualAmount ); - error Easy2Pay__PaymentAlreadyCompleted(); - error Easy2Pay__FailedToSendEther(); - error Easy2Pay__UnauthorizedAccess(); + error EasyPay__PaymentAlreadyCompleted(); + error EasyPay__FailedToSendEther(); + error EasyPay__UnauthorizedAccess(); modifier onlyOwner() { - if (msg.sender != owner) revert Easy2Pay__UnauthorizedAccess(); + if (msg.sender != owner) revert EasyPay__UnauthorizedAccess(); _; } @@ -50,12 +50,12 @@ contract Easy2Pay { PayRequest storage request = payRequests[_requestId]; if (request.receiver == address(0)) - revert Easy2Pay__RequestDoesNotExist(); + revert EasyPay__RequestDoesNotExist(); if (request.amount > msg.value) - revert Easy2Pay__InsufficientEther(request.amount, msg.value); + revert EasyPay__InsufficientEther(request.amount, msg.value); - if (request.completed) revert Easy2Pay__PaymentAlreadyCompleted(); + if (request.completed) revert EasyPay__PaymentAlreadyCompleted(); request.completed = true; @@ -63,17 +63,17 @@ contract Easy2Pay { // This is the current recommended method to use to transfer ETH. (bool sent, ) = request.receiver.call{value: msg.value}(""); - if (!sent) revert Easy2Pay__FailedToSendEther(); + if (!sent) revert EasyPay__FailedToSendEther(); } // Function in case a payment is received where msg.data must be empty receive() external payable { - if (msg.sender != address(0)) revert Easy2Pay__FailedToSendEther(); + if (msg.sender != address(0)) revert EasyPay__FailedToSendEther(); } // Fallback function is called when msg.data is not empty fallback() external payable { - if (msg.sender != address(0)) revert Easy2Pay__FailedToSendEther(); + if (msg.sender != address(0)) revert EasyPay__FailedToSendEther(); } function setOwner(address _newOwner) public onlyOwner { diff --git a/packages/foundry/script/Deploy.s.sol b/packages/foundry/script/Deploy.s.sol index 00a73c9..a959ca8 100644 --- a/packages/foundry/script/Deploy.s.sol +++ b/packages/foundry/script/Deploy.s.sol @@ -15,13 +15,11 @@ contract DeployScript is ScaffoldETHDeploy { ); } vm.startBroadcast(deployerPrivateKey); - EasyPay easyPay = new EasyPay( - // vm.addr(deployerPrivateKey) - ); + EasyPay easyPay = new EasyPay(); console.logString( string.concat( "EasyPay deployed at: ", - vm.toString(address(yourContract)) + vm.toString(address(easyPay)) ) ); vm.stopBroadcast();