gasless

1.0.3 • Public • Published

Gasless.js

Send DAI without ETH in your app

Features

  • Gasless DAI transfers via the Mosendo API
  • Browser & Node.js support
  • Injected web3 provider (e.g. Metamask) support
  • EIP712 for readable user signed messages

Getting Started

npm i --save gasless

Usage

Injected Web3 Provider (e.g. Metamask)

import Gasless from 'gasless';
 
(async ()=>{
 
    await window.ethereum.enable();
    const gasless = new Gasless(window.web3.currentProvider);
    const gasPrice = await window.web3.eth.getGasPrice();
    const daiFee = await gasless.getFee(gasPrice);
    const from = window.web3.eth.defaultAccount;
    const txHash = await gasless.send(
        from,     // Sender address                   (string)
        to,       // Recipient address                (string)
        value,    // base unit DAI amount             (string)
        daiFee    // Base unit DAI fee.               (string)
        gasPrice  // Tx gas price in Wei.             (string)
    );
 
})()

Custom Web3 Provider

Please make sure that your custom provider supports EIP712 signTypedData_v3.

Just replace window.web3.currentProvider in the example above with your custom provider.

Readme

Keywords

Package Sidebar

Install

npm i gasless

Weekly Downloads

4

Version

1.0.3

License

MIT

Unpacked Size

436 kB

Total Files

28

Last publish

Collaborators

  • mosendotechteam