All Projects → vittominacori → erc1363-payable-token

vittominacori / erc1363-payable-token

Licence: MIT license
Code implementation for the ERC-1363 Payable Token

Programming Languages

javascript
184084 projects - #8 most used programming language
solidity
1140 projects
shell
77523 projects

Projects that are alternatives of or similar to erc1363-payable-token

ethereum-erc20
Fungible token implementation for the Ethereum blockchain.
Stars: ✭ 27 (-67.47%)
Mutual labels:  smart-contracts, token, eip, erc20
Awesome Blockchain Kor
<블록체인의 정석>, <하이퍼레저 블록체인 개발> 소스코드 및 참고자료 저장소
Stars: ✭ 243 (+192.77%)
Mutual labels:  smart-contracts, token, erc20
ethereum-contracts
Knowledge Ethereum Smart Contracts
Stars: ✭ 41 (-50.6%)
Mutual labels:  smart-contracts, truffle, token
Erc20 Generator
Create an ERC20 Token for FREE in less than a minute with the most used Smart Contract Generator for ERC20 Token. No login. No setup. No coding required.
Stars: ✭ 202 (+143.37%)
Mutual labels:  smart-contracts, truffle, erc20
ethereum-crowdsale
0xcert protocol crowdsale contracts for Ethereum blockchain.
Stars: ✭ 15 (-81.93%)
Mutual labels:  smart-contracts, token, erc20
Simple-Game-ERC-721-Token-Template
🔮 Very Simple ERC-721 Smart Contract Template to create your own ERC-721 Tokens on the Ethereum Blockchain, with many customizable Options 🔮
Stars: ✭ 83 (+0%)
Mutual labels:  smart-contracts, token
create-truffle-dapp
Create and deploy Truffle projects with no configuration.
Stars: ✭ 17 (-79.52%)
Mutual labels:  smart-contracts, truffle
blockstarter
This is a white label solution to create a contribution crypto-wallet that can be used in your ICO campaign.
Stars: ✭ 21 (-74.7%)
Mutual labels:  smart-contracts, token
web3j-example
Android web3j example
Stars: ✭ 27 (-67.47%)
Mutual labels:  smart-contracts, truffle
eth-decoder
Simple library to decode ethereum transaction and logs
Stars: ✭ 32 (-61.45%)
Mutual labels:  smart-contracts, truffle
starter-kit-gsn
An OpenZeppelin starter kit focused on GSN.
Stars: ✭ 39 (-53.01%)
Mutual labels:  smart-contracts, truffle
koinos-gui-miner
The Koinos Miner (GUI) provides a sleek and functional user interface that allows users to mine the KOIN ERC-20 which will be used to deliver an equitable initial token distribution on the Koinos blockchain.
Stars: ✭ 26 (-68.67%)
Mutual labels:  smart-contracts, erc20
solidity-contracts
📦 Resources for the Ethereum Smart Contract Development tutorial series.
Stars: ✭ 64 (-22.89%)
Mutual labels:  smart-contracts, truffle
starter-kit-tutorial
An OpenZeppelin starter kit tutorial containing React, OpenZeppelin SDK & OpenZeppelin Contracts.
Stars: ✭ 34 (-59.04%)
Mutual labels:  smart-contracts, openzeppelin
proof-of-existence
Ethereum Smart Contract to prove a document's existence at some point by storing and verifying its hash.
Stars: ✭ 22 (-73.49%)
Mutual labels:  smart-contracts, truffle
trufflepig
🍄🐷Truffle contract artifact loading tool for local development
Stars: ✭ 45 (-45.78%)
Mutual labels:  smart-contracts, truffle
tokenbridge
A bidirectional Ethereum / RSK Token Bridge implementation.
Stars: ✭ 85 (+2.41%)
Mutual labels:  token, erc20
etherbrite
🗓 Clone eventbrite on Ethereum, built in Solidity, TruffleJS, Web3js and React/Redux.
Stars: ✭ 19 (-77.11%)
Mutual labels:  smart-contracts, truffle
erc721
The reference implementation of the ERC-721 non-fungible token standard.
Stars: ✭ 989 (+1091.57%)
Mutual labels:  smart-contracts, token
BatchPayments
A gas conscious batch payment implementation
Stars: ✭ 27 (-67.47%)
Mutual labels:  token, erc20

ERC-1363 Payable Token

NPM Package CI Coverage Status MIT licensed

ERC-1363 allows to implement an ERC-20 token that can be used for payments.

This is an implementation of the ERC-1363 Payable Token that defines a token interface for ERC-20 tokens that supports executing recipient code after transfer or transferFrom, or spender code after approve in a single transaction.

Abstract

There is no way to execute code after an ERC-20 transfer or approval (i.e. making a payment), so to make an action it is required to send another transaction and pay GAS twice.

This proposal wants to make token payments easier and working without the use of any other listener. It allows to make a callback after a transfer or approval in a single transaction.

There are many proposed uses of Ethereum smart contracts that can accept ERC-20 payments.

Examples could be

  • to create a token payable crowdsale
  • selling services for tokens
  • paying invoices
  • making subscriptions

For these reasons it was originally named as "Payable Token".

Anyway you can use it for specific utilities or for any other purposes who require the execution of a callback after a transfer or approval received.

Install

npm install erc-payable-token

Usage

pragma solidity ^0.8.0;

import "erc-payable-token/contracts/token/ERC1363/ERC1363.sol";

contract MyToken is ERC1363 {

    constructor (
        string memory name,
        string memory symbol
    ) ERC20(name, symbol) {
        // your stuff
    }

  // your stuff
}

Code

This repo contains:

IERC1363

IERC1363.sol

Interface for a Payable Token contract as defined in ERC-1363 Payable Token.

interface IERC1363 is IERC20, IERC165 {
    function transferAndCall(address to, uint256 amount) external returns (bool);
    function transferAndCall(address to, uint256 amount, bytes calldata data) external returns (bool);
    function transferFromAndCall(address from, address to, uint256 amount) external returns (bool);
    function transferFromAndCall(address from, address to, uint256 amount, bytes calldata data) external returns (bool);
    function approveAndCall(address spender, uint256 amount) external returns (bool);
    function approveAndCall(address spender, uint256 amount, bytes calldata data) external returns (bool);
}

ERC1363

ERC1363.sol

Implementation of an IERC1363 interface.

IERC1363Receiver

IERC1363Receiver.sol

Interface for any contract that wants to support transferAndCall or transferFromAndCall from ERC1363 token contracts.

interface IERC1363Receiver {
    function onTransferReceived(address operator, address sender, uint256 amount, bytes calldata data) external returns (bytes4);
}

IERC1363Spender

IERC1363Spender.sol

Interface for any contract that wants to support approveAndCall from ERC1363 token contracts.

interface IERC1363Spender {
    function onApprovalReceived(address sender, uint256 amount, bytes calldata data) external returns (bytes4);
}

ERC1363Payable

ERC1363Payable.sol

Implementation proposal of a contract that wants to accept ERC1363 payments. It intercepts what is the ERC1363 token desired for payments and throws if another is sent.

It emits a TokensReceived event to notify the transfer received by the contract.

It also implements a transferReceived function that can be overridden to make your stuffs within your contract after a onTransferReceived.

It emits a TokensApproved event to notify the approval received by the contract.

It also implements a approvalReceived function that can be overridden to make your stuffs within your contract after a onApprovalReceived.

ERC1363PayableCrowdsale

ERC1363PayableCrowdsale.sol

As example: an Implementation of a classic token Crowdsale, but paid with ERC1363 tokens instead of ETH.

Development

Install dependencies

npm install

Linter

Use Solhint

npm run lint:sol

Use ESLint

npm run lint:js

Use Eslint and fix

npm run lint:fix

Usage (using Truffle)

Open the Truffle console

npm run truffle:console

Compile

npm run truffle:compile

Test

npm run truffle:test

Usage (using Hardhat)

Open the Hardhat console

npm run hardhat:console

Compile

npm run hardhat:compile

Test

npm run hardhat:test

Code Coverage

npm run hardhat:coverage

License

Code released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].