PHPackages                             cryptom2/magento-discount-token - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. cryptom2/magento-discount-token

ActiveMagento2-module[Utility &amp; Helpers](/categories/utility)

cryptom2/magento-discount-token
===============================

Magento 2 ERC20 token discount extension

v1.0.1(3y ago)6131MITPHP

Since Oct 13Pushed 3y ago2 watchersCompare

[ Source](https://github.com/torys877/crypto-magento-discount-token)[ Packagist](https://packagist.org/packages/cryptom2/magento-discount-token)[ RSS](/packages/cryptom2-magento-discount-token/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Crypto MagentoToken Magento 2 Extension
=======================================

[](#crypto-magentotoken-magento-2-extension)

Magento 2 module allows to use ERC20 tokens as discount

Description
-----------

[](#description)

Extension allows to collect and use tokens, similar to customer balance functional. Tokens are charged after order placement and customer can use this balance as discount for new orders.

Additionally, customer can claim his tokens from magento store to own metamask wallet and use these tokens in another magento store.

Extension allows to implement complex discount or partnership program between magento stores.

This functional uses signed messages to sign claiming requests from store side and use signed message on customer side for claiming tokens. It means store owner does not need pay any GAS for sending tokens to customer. Customer pays all network taxes (gas) when use signed message to claim tokens in customer area.

Features
--------

[](#features)

1. Collect 'local discount token' inside magento store for order
2. Use 'discount token' for new order to get discount
3. Customer can send withdraw request for claiming tokens from customer account
4. Store owner can sign customer's request using own metamask account
5. Customer can claim token in own account using signed message

Installation
------------

[](#installation)

To install module you need to add repositories to your `composer.json`:

### Composer installation

[](#composer-installation)

`composer require cryptom2/magento-discount-token:v1.0.0`

### Magento run

[](#magento-run)

```
php bin/magento setup:upgrade

```

### Settings

[](#settings)

[![Checkout Payment Page](https://raw.githubusercontent.com/torys877/crypto-magento-discount-token/main/docs/settings.png)](https://raw.githubusercontent.com/torys877/crypto-magento-discount-token/main/docs/settings.png)

- **Enable** - enable/disable token functional
- **Percent Of Order Grand Total** - how much tokens customer can take from order grand total in percent
- **Multiplier** - multiplier for tokens (ex. if grand total = 50$, percent = 4, multiplier = 100 - customer will have = `50 * 0.04 * 100` = `200` tokens. And for discount it will be `{grand_total} - {tokens}/{multiplier}`)
- **Token Symbol** - Symbol of token used in ERC20 token creation
- **Token Name** - Token name used in ERC20 token creation
- **Token Address** - address of ERC20 token
- **Smart Contract Address** - address of smart contract that will manage tokens to claim tokens and sign customer requests
- **Smart Contract Abi** - Abi of smart contract

How to use
----------

[](#how-to-use)

### Deploy ERC20 Token and Control Smart Contract

[](#deploy-erc20-token-and-control-smart-contract)

#### Hardhat

[](#hardhat)

To deploy ERC20 token and smart contract you can use Hardhat. Install hardhat and copy folders from hardhat folder in current module to hardhat root directory.

Then run from hardhat root directory:

`npx hardhat node` - to run node

`npx hardhat run --network localhost .\scripts\deploy.js`

#### Remix Ide

[](#remix-ide)

To deploy contracts using Remix IDE you need download IDE or use web remix IDE. You need copy all files from directory `hardhat/contracts` and:

1. deploy `MagentoDiscountToken.sol`
2. deploy `ControlContract.sol` using address of MagentoDiscountToken that you should get after `step1`.

***Important:***

**you must use the same own address to deploy both contracts. This address should be 'store owner address' and you must have full control for this address.**

### Approve Control Contract Actions

[](#approve-control-contract-actions)

After deploying both contracts and ERC20 token you will have 1 million tokens on your address.

And you need allow control contract to manage your tokens to allow customers claim it. To allow control contract to manage your tokens you need run `approve` function on MagentoDiscountToken.

There is necessary to input Control Smart Contract Address in field `spender` and amount of tokens in field `amount` that smart contract can use.

[![Checkout Payment Page](https://raw.githubusercontent.com/torys877/crypto-magento-discount-token/main/docs/approve.png)](https://raw.githubusercontent.com/torys877/crypto-magento-discount-token/main/docs/approve.png)

**Remember** - you have 1 mln tokens, but totalsupply will show you `1 000 000 * 10**18`. It was made to imitate the same relation as Ether and Wei, so it allows to implement decimals with 18 zero after dot.

So to allow your smart contract use only `2000` of tokens from your account you should input `2000 * 10**18`, final amount will be `2000000000000000000000`.

Screenshots
-----------

[](#screenshots)

### Menu

[](#menu)

Admin panel has 4 menu:

- **Token Balances** - token balance grid associated with customers
- **Token History** - history of all action with token balance (add/claim/refund etc)
- **Token Orders** - orders table with token balance per order
- **Withdraw Requests** - customer token withdraw requests (there is possible to sign message to allow customer claims his token)

[![Admin Menu](https://raw.githubusercontent.com/torys877/crypto-magento-discount-token/main/docs/admin_menu.png)](https://raw.githubusercontent.com/torys877/crypto-magento-discount-token/main/docs/admin_menu.png)

### Withdraw Requests

[](#withdraw-requests)

There is possible to sign request using your metamask. Signing is not use any gas and it is only local operation. After signing message request will change status and customer can claim tokens using signed message hash.

[![Withdraw Request](https://raw.githubusercontent.com/torys877/crypto-magento-discount-token/main/docs/admin_sign.png)](https://raw.githubusercontent.com/torys877/crypto-magento-discount-token/main/docs/admin_sign.png)

### Customer Token Balance Page

[](#customer-token-balance-page)

Customer page with balances. Customer can:

- See his token balance
- Send request to claim tokens with amount he would like to claim
- See his requests for claiming tokens with request status. If request has signed by store owner customer sees button `Claim Tokens`
- Claims his tokens by click on button `Claim Tokens` in request grid

[![Withdraw Request](https://raw.githubusercontent.com/torys877/crypto-magento-discount-token/main/docs/customer_token_balance.png)](https://raw.githubusercontent.com/torys877/crypto-magento-discount-token/main/docs/customer_token_balance.png)

TODO
----

[](#todo)

- add possibility to top up customer ERC20 token balance in customer account from his metamask wallet
- fix js issue with double click on claim and sign buttons
- feel free to fork and fix/implement anything if you are interested

Author
------

[](#author)

### Ihor Oleksiienko

[](#ihor-oleksiienko)

- [Github](https://github.com/torys877)
- [Linkedin](https://www.linkedin.com/in/igor-alekseyenko-77613726/)
- [Facebook](https://www.facebook.com/torysua/)

License
-------

[](#license)

Magento ERC20 Discount Token extension for Magento 2 is licensed under the MIT License - see the LICENSE file for details

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~156 days

Total

2

Last Release

1202d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/68833022e981b0897094481a2ca162b5a862478a83f434aca3f9691b4567ec0f?d=identicon)[Torys877](/maintainers/Torys877)

---

Top Contributors

[![philpher0x](https://avatars.githubusercontent.com/u/46719294?v=4)](https://github.com/philpher0x "philpher0x (6 commits)")

---

Tags

discounterc20erc20-discounterc20-loyaltyerc20-tokenethereumethereum-blockchainloyaltyloyalty-pointsloyalty-rewardsloyalty-solutionsloyaltymarketingmagento2magento2-modulemetamaskweb3

### Embed Badge

![Health badge](/badges/cryptom2-magento-discount-token/health.svg)

```
[![Health](https://phpackages.com/badges/cryptom2-magento-discount-token/health.svg)](https://phpackages.com/packages/cryptom2-magento-discount-token)
```

###  Alternatives

[bluem/tree

Library for handling tree structures based on parent IDs

251953.3k7](/packages/bluem-tree)[leandrocfe/filament-ptbr-form-fields

Brazilian pt-BR form fields.

147118.4k](/packages/leandrocfe-filament-ptbr-form-fields)[jacksleight/statamic-bard-texstyle

18195.4k](/packages/jacksleight-statamic-bard-texstyle)[micropackage/ajax

Wrapper for WordPress' AJAX

1120.3k](/packages/micropackage-ajax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
