npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

delegated-transfer-token

v0.2.0

Published

Send a token using just that token, no Ether needed.

Downloads

19

Readme

Delegated Transfer Token

On Ethereum, you need Ether and the token just to send the token. Needing two currencies just to send one sucks. Delegated transfer tokens make it better.

With delegated transfer tokens, you can send a token using just that token. No need to have Ether in your wallet just to send money.

Get started

  1. Install the contracts
npm install --save delegated-transfer-token
  1. Import them into your project! I highly recommend using them alongside OpenZeppelin contracts.
pragma solidity ^0.8.4;

import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import 'delegated-transfer-token/contracts/DTT.sol';

contract DTTBasic20 is ERC20, DTT {
  constructor(string memory name, string memory symbol) ERC20(name, symbol) {
    // Mint 200 tokens when the contract is deployed
    _mint(_msgSender(), 200 * (10 ** decimals()));
  }
}

How does it work?

The DTT contract extends the ERC20 standard to introduce a delegatedTransfer() function. It lets users define normal transfer parameters in addition to a nonce, chain ID, signature, and fee designating the number of tokens paid to the transaction delegate. See contracts/DTT.sol and related examples for more details.

function delegatedTransfer(
  address sender,
  address recipient,
  uint256 amount,
  uint256 fee,
  address tokenAddress,
  uint256 nonce,
  uint256 chainId,
  bytes memory signature
)

Let's say Alice wants to pay Charlie in DTT, but she doesn't have any Ether in her wallet. Here's how she can use delegatedTransfer() with Bob's help to send money to Charlie.

  1. Alice tells Bob she wants to send some DTT to Charlie
  2. Bob tells Alice how much DTT he wants in order to submit the transaction
  3. Alice agrees on the fee, signs the payload (all the parameters in the delegatedTransfer function), and gives the payload and signature to Bob
  4. Bob calls delegatedTransfer() with the agreed parameters and Alice's signature

DONE! Charlie receives Alice's payment and Bob earns his fees as a delegate once the transaction is confirmed. Here, Bob is the only one that has some Ether.

What is it, really?

DTTs are a new token pattern inspired by the ERC-865 token standard. It maintains the standard's motivation of allowing users to pay transaction fees in the desired token, but it resolves the security concerns the standard had (namely replay attacks).

DTTs are also ERC20-compatible, so if you want to do old-style token transfers you can!

Why this?

One of the worst experiences Ethereum users have is needing Ether and a token to send the token. It's a confusing process that's hindering adoption of cryptocurrencies overall. DTTs provide the refreshing and familiar experience of sending money with just that money alone.

DTTs also provide businesses and individuals new revenue models by enabling a fee market: people can compete to earn fees in the desired token by offering users the best prices and fastest transaction speeds possible.

But crypto people don't like third parties

"Crypto people" don't like trusted third parties. Because a delegate is only relaying a user's signature to the chain, they can't modify it to steal money.

Users only need to trust that delegates will actually submit the transaction, not that they can change its details.

Be mindful of the license.

LICENSE

Delegated Transfer Token Copyright (C) 2021 Gerald Nash

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.