Note

This documentation is a work in progress.

gasstationlib

The gasstationlib allows you to easily create the required data for posting gas-requests to a gasstation REST API.


Including gasstation lib in your frontend

using webpack

You can add the gasstation library to your frontend project by installing the module via NPM npm install ethereumgasstation.

Add the gasstation to your webpack build

In your webpack.js add the following:

import
        gasstationlib
from 'ethereumgasstation/lib/gasstationlib.js';

export { gasstationlib }

And create an instance of the library , providing the web3.currentProvider to read data from the blockchain ( nonces , balances etc. ).

let gasstationlib = webpack.gasstationlib({
  currentProvider: web3.currentProvider
});

signGastankParameters

Create and sign the gastank parameters

let clientSig = gasstationlib.signGastankParameters(
                                tokenInfo.address,
                                serverInstance.options.contractaddress,
                                fillrequestResponse.tokens,
                                fillrequestResponse.gas,
                                fillrequestResponse.validuntil,
                                gasstationCustomer.private);

getApprovalTx

Create the approval transaction

gasstationlib.getApprovalTx(
        gasstationCustomer.public,
        gasstationCustomer.private,
        tokenInfo.address,
        fillrequestResponse.tokens,
        serverInstance.options.contractaddress
).then((approvalTx) => {
        ...
});