Coder Social home page Coder Social logo

jay-s-block / project-block-subs Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 1.76 MB

The BlockSubs smart contract is a decentralized subscription management system implemented on the Ethereum blockchain.

Home Page: https://blocksubs.jaykeraliya.com

License: MIT License

CSS 0.09% TypeScript 73.16% Solidity 8.29% JavaScript 18.46%
blockchain ethereum ethereum-development smart-contract solidity subscription-management web3

project-block-subs's Introduction

BlockSubs Smart Contract

The BlockSubs smart contract is a decentralized subscription management system implemented on the Ethereum blockchain. It allows users to register, subscribe to different roles, and manage their subscriptions using ERC20 tokens. This smart contract can be used as a foundation for building subscription-based applications on the blockchain.

Features

User Registration

Users can register by providing their name through the registerUser function. Once registered, a user can manage their subscription status and interact with the contract.

Subscription Roles

The smart contract defines different subscription roles: Silver, Gold, Platinum, and Diamond. Each role has a specific price associated with it, which is set by the contract owner. Users can subscribe to a particular role by calling the addSubscription function and providing the desired role. The subscription is active for a fixed duration of 30 days, after which it expires.

Subscription Status

The contract keeps track of the user's subscription status, including the active role, expiration timestamp, and cancellation time. Users can query their own subscription status using the getUser function.

Subscription Cancellation

Users have the option to cancel their active subscription at any time by calling the cancelSubscription function. If a subscription is canceled before its expiration, the user is eligible for a refund based on the remaining time. The refund amount is calculated proportional to the remaining subscription time and deducted from the contract's balance.

Token Minting

The smart contract supports minting and transfer of ERC20 tokens, referred to as BlockSubs (BSB) tokens. Users can mint tokens by calling the mintTokens function and providing the desired amount. The minting process requires an equivalent payment in Ether (ETH) based on the predefined token price. The maximum minting amount per wallet is set to 2000 tokens.

Token Transfers

Users can transfer their BSB tokens to other addresses using the transfer and transferFrom functions. The contract ensures that the sender has a sufficient balance and the transfer amount does not exceed the available balance or allowance.

Ownership and Access Control

The smart contract utilizes the OpenZeppelin Ownable contract to manage ownership and access control. The contract owner can set the prices for each subscription role and perform administrative tasks.

Deployment

  1. Install the Truffle framework.
npm install -g truffle
  1. Clone the repository and install the dependencies:
git clone
cd project-block-subs
npm install
  1. Compile and test the smart contract:
truffle compile
truffle test
  1. Deploy the smart contract to a blockchain:
truffle dashboard

Connect wallet to the dashboard and deploy the contract to a local or remote network.

truffle migrate --network dashboard
  1. Copy the contract address and ABI from the dashboard and use them in your application.

  2. (Optional) Verify the contract on Etherscan.

  3. Deploy the frontend application to vercel.

Deploy to Vercel

License

The BlockSubs project is licensed under the MIT License.

Disclaimer

This smart contract is provided as-is without any warranties or guarantees. Use it at your own risk. The contract author and contributors are not responsible for any loss of funds or damages caused by the usage of this contract.

project-block-subs's People

Contributors

dependabot[bot] avatar henil999 avatar jaykeraliya0 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

project-block-subs's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.