This project implements a subscription actions using Solidity. Users can subscribe and cancel their subscriptions via a deployed smart contract.
- Subscribe by paying a fixed fee
- Cancel a subscription and receive a refund
- Events to track subscription activities
- Interact using Ethers.js.
git clone https://github.com/chang96/partnr-subscription.git
cd partnr-subscriptionnpm installCreate a .env file in the root directory and add:
SEPOLIA_RPC_URL=YOUR_ALCHEMY_OR_INFURA_URL
PRIVATE_KEY=YOUR_WALLET_PRIVATE_KEY
CONTRACT_ADDRESS=DEPLOYED_CONTRACT_ADDRESSTo deploy the contract to a testnet (e.g., Sepolia):
npx hardhat run scripts/deploy.ts --network sepoliaUse Ethers.js to interact with the contract. The functions are located in etherjs-sample.ts.
- Subscribe:
subscribe() - Cancel Subscription:
cancelSubscription() - Check Subscription Status:
checkSubscription(userAddress)
Run automated tests using Hardhat:
npx hardhat testMIT