Skip to content

Smart Contract Repository for TipMe. TipMe is decentralized application (DApp), a personal tipping website built with Next.js. It provides a user-friendly interface for interacting with the `TipMe` smart contract on the blockchain.

Notifications You must be signed in to change notification settings

MastayY/tipme-smart-contract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TipMe - Personal Tipping DApp

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.

Smart Contract Features

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 NewSpecialTip event, 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.

Technology Stack

  • 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.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Node.js
  • Bun or another package manager like npm or yarn.

Installation

  1. Clone the repository.

  2. Navigate to the hardhat directory and install the dependencies:

    cd hardhat
    bun install

Compiling the Contract

To compile the smart contract, run the following command:

bunx hardhat compile

This will generate the contract artifacts in the artifacts directory.

Running Tests

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.

  1. Start a local Hardhat node:

    bunx hardhat node
  2. In a new terminal, run the test script:

    bunx hardhat run scripts/send-tip.ts --network localhost

Deployment

The project is configured for deployment to various networks, including baseSepolia.

Setting Up Environment Variables with Hardhat Keystore

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.

  1. 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
  2. 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_KEY

    This will prompt you to enter your private key securely. Never commit your private key to version control.

  3. 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.

Deploying the contract

To deploy the contract to baseSepolia, run the following command:

bunx hardhat run scripts/deploy.ts --network baseSepolia

The script will deploy the TipMe contract and log the contract address to the console. After deployment, you can verify your contract on Basescan.

Interacting with the Contract

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.

Deployed Contract

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.

About

Smart Contract Repository for TipMe. TipMe is decentralized application (DApp), a personal tipping website built with Next.js. It provides a user-friendly interface for interacting with the `TipMe` smart contract on the blockchain.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published