This project is a decentralized application (DApp) that allows anyone to create a personal tipping page to receive tips in cryptocurrency. It features a smart contract to handle the logic of receiving tips, setting funding goals, and withdrawing funds. The frontend is built with Next.js.
This repository contains the Hardhat project for the TipMe smart contract.
The TipMe.sol smart contract includes the following features:
- Receive Tips: Users can send tips in the native cryptocurrency (e.g., ETH).
 - Funding Goals: The owner can set a funding goal with a target amount.
 - Special Tips: Tips above a certain threshold are emitted as a 
NewSpecialTipevent, allowing the frontend to highlight them. - Secure Withdrawals: The owner can withdraw the entire contract balance to a specified address. Withdrawals have a cooldown period to prevent rapid, repeated withdrawals.
 - Ownership: The contract is ownable, with administrative functions restricted to the owner.
 - Pausable: The contract can be paused by the owner, halting all tip-related functions in case of an emergency.
 - Reentrancy Guard: Protects against reentrancy attacks.
 
- Solidity: The language used for writing the smart contract.
 - Hardhat 3: An Ethereum development environment for compiling, deploying, testing, and debugging smart contracts.
 - viem: A TypeScript Interface for Ethereum.
 - OpenZeppelin Contracts: A library of secure and community-vetted smart contract components.
 - Bun: A fast, all-in-one JavaScript runtime and toolkit used for package management.
 
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- 
Clone the repository.
 - 
Navigate to the
hardhatdirectory and install the dependencies:cd hardhat bun install 
To compile the smart contract, run the following command:
bunx hardhat compileThis will generate the contract artifacts in the artifacts directory.
While this project doesn't have a formal test suite, you can test the addTip functionality by running the send-tip.ts script on a local network.
- 
Start a local Hardhat node:
bunx hardhat node
 - 
In a new terminal, run the test script:
bunx hardhat run scripts/send-tip.ts --network localhost
 
The project is configured for deployment to various networks, including baseSepolia.
To deploy to a live network and verify your contract, you need to set a few configuration variables. The Hardhat configuration uses configVariable for these, and you can set them using the hardhat-keystore plugin.
- 
Set the Base Sepolia RPC URL: This is the URL of the RPC endpoint for the Base Sepolia network. You can get one from a provider like Infura or Alchemy.
bunx hardhat keystore set BASE_SEPOLIA_RPC_URL - 
Set the Private Key: This is the private key of the account you want to use for deployment.
bunx hardhat keystore set BASE_SEPOLIA_PRIVATE_KEYThis will prompt you to enter your private key securely. Never commit your private key to version control.
 - 
Set the Etherscan API Key: This is required to verify your contract on block explorers like Etherscan or Basescan. You can get an API key from your Basescan account.
bunx hardhat keystore set ETHERSCAN_API_KEY 
After setting these variables, you can deploy the contract.
To deploy the contract to baseSepolia, run the following command:
bunx hardhat run scripts/deploy.ts --network baseSepoliaThe script will deploy the TipMe contract and log the contract address to the console. After deployment, you can verify your contract on Basescan.
The scripts directory contains examples of how to interact with the deployed contract.
deploy.ts: Deploys the contract with an initial owner, goal, and goal amount.send-tip.ts: Deploys a new contract on a local network and sends a test tip to it.
You can adapt these scripts to interact with your deployed contract on any network.
You can interact with the deployed TipMe contract on the Base Sepolia test network.
- Contract Address: 
0x4780a2F6A431abA33C7746448b173213adfe83E8 - Base Sepolia Explorer: You can view the contract on the Base Sepolia.