The Plebbit tipping system includes the smart contract and the JavaScript/TypeScript API.
Related Project: plebones - A bare-bones GUI client for Plebbit that provides a minimal interface for interacting with Plebbit networks and integrates with the tipping system on Sepolia (Etherium Testnet). It contains the tipping react-hooks which are leveraging the js-api from this project.
Live Demo: plebtip.netlify.app - A web-based tipping interface built with plebones and this smart contract and js-api
| Network | Contract Address |
|---|---|
| Sepolia | 0x49753cB4ff375e04D2BC2A64971F60cD1a091381 |
| Amoy | 0x49753cB4ff375e04D2BC2A64971F60cD1a091381 |
| Base Sepolia | 0x49753cB4ff375e04D2BC2A64971F60cD1a091381 |
- tip: Allows users to send tips to other users with an optional comment.
- getTipsTotalAmount: Gets the total tip amount for a particular comment and fee recipients.
- getTips: Retrieves the list of tips for a comment.
- Access control with admin and moderator roles using OpenZeppelin's AccessControl.
- Deterministic contract address deployment across different chains.
- Node.js (preferably LTS)
- npm
-
Clone the repository:
git clone <your-repo-url> cd plebbit-tipping-v1
-
Install dependencies for both contracts and js-api:
npm install
-
Build everything (contracts + js-api):
npm run build
-
Copy ADMIN_ADDRESS and RPC API-KEY's to .env
cp .env.example contracts/.env cp .env.example js-api/.env
Execute the following command to run in one terminal:
npm run node Execute the following command to run the tests:
npm testStart a local Hardhat node:
npm run nodeDeploy the contract locally:
npm run deploy:localhostFor general deployment:
npm run deployYou can run tests against a fork of the current Ethereum mainnet using Hardhat.
You'll need an RPC URL from a provider like Alchemy or Infura.
-
Set your mainnet RPC URL as an environment variable e.g. in .env or:
export MAINNET_RPC_URL="https://eth-mainnet.g.alchemy.com/v2/your-api-key"
-
Start a Hardhat node forked from mainnet:
npx hardhat node --fork $MAINNET_RPC_URL -
In a new terminal, run the tests:
npm test
npx hardhat deploy --network sepolianpx hardhat deploy --network amoynpx hardhat deploy --network baseSepoliaAfter deploying to a testnet, you can verify your contract on the relevant block explorer (Etherscan for Sepolia, Polygonscan for Amoy) using the following scripts:
npm run verify:sepolia -- <DEPLOYED_CONTRACT_ADDRESS> <CONSTRUCTOR_ARGS>
or
npm run verify:amoy -- <DEPLOYED_CONTRACT_ADDRESS> <CONSTRUCTOR_ARGS>
Replace <DEPLOYED_CONTRACT_ADDRESS> with your contract's address and <CONSTRUCTOR_ARGS> with any constructor arguments (if any).
tip(address recipient, uint256 amount, address feeRecipient, bytes32 senderCommentCid, bytes32 recipientCommentCid)getTipsTotalAmount(bytes32 recipientCommentCid, address[] calldata feeRecipients)getTipsTotalAmounts(bytes32[] calldata recipientCommentCids, address[][] calldata feeRecipients)getTipsTotalAmountsSameFeeRecipients(bytes32[] calldata recipientCommentCids, address[] calldata feeRecipients)getTipsAmounts(bytes32 recipientCommentCid, address[] calldata feeRecipients, uint256 offset, uint256 limit)getTips(bytes32 recipientCommentCid, address[] calldata feeRecipients, uint256 offset, uint256 limit)getSenderTipsTotalAmount(bytes32 senderCommentCid, address sender, bytes32 recipientCommentCid, address[] calldata feeRecipients)getSenderTipsTotalAmounts(bytes32 senderCommentCid, address sender, bytes32[] calldata recipientCommentCids, address[][] calldata feeRecipients)getSenderTipsTotalAmountsSameFeeRecipients(bytes32 senderCommentCid, address sender, bytes32[] calldata recipientCommentCids, address[] calldata feeRecipients)
setMinimumTipAmount(uint256 _minimumTipAmount)- Only moderatorssetFeePercent(uint256 _feePercent)- Only moderators (1-20%)
This project is licensed under the MIT License.