Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

daofi-metatx

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

daofi-metatx

Sign permit messages for Ethereum tokens

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

eth-permit

This package simplifies the process of signing permit messages for Ethereum tokens.

What is permit?

Permit is a technique for metatransaction token transfers. Using permit can allow a contract to use a user's tokens without the user first needing to first to send an approve() transaction.

Permit variations

Permit was first introduced in the Multi-Collateral Dai token contract.

The permit technique is being standardized as part of ERC-2612. This standard (which has already been implemented in projects like Uniswap V2) is slightly different than the implementation used by Dai. Therefore, this library provides functions for signing both types of messages.

Usage

Install the package eth-permit using npm or yarn.

Dai-style permits

import { signDaiPermit } from 'eth-permit';

// Sign message using injected provider (ie Metamask).
// You can replace window.ethereum with any other web3 provider.
const result = await signDaiPermit(window.ethereum, tokenAddress, senderAddress, spender);

await token.methods.permit(senderAddress, spender, result.nonce, result.expiry, true, result.v, result.r, result.s).send({
  from: senderAddress,
});

ERC2612-style permits

import { signERC2612Permit } from 'eth-permit';

const value = web3.utils.toWei('1', 'ether');

// Sign message using injected provider (ie Metamask).
// You can replace window.ethereum with any other web3 provider.
const result = await signERC2612Permit(window.ethereum, tokenAddress, senderAddress, spender, value);

await token.methods.permit(senderAddress, spender, value, result.deadline, result.v, result.r, result.s).send({
  from: senderAddress,
});

FAQs

Package last updated on 05 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc