1

Version of EOSJS eos@fffff and eos@beta3

Describe the bug

const JsSignatureProvider = require('eosjs/dist/eosjs-jssig');
const signature = new JsSignatureProvider([privKey]);

TypeError: JsSignatureProvider is not a constructor

Steps to reproduce the behavior: try and follow the first 6 lines of the documentation for getting started

Expected behavior: works

Desktop (please complete the following information): Ubuntu 16.04. node 8.14.0

Smartphone (please complete the following information): no

2 Answers 2

0

try .default at the end of the sig providor module

const JsSignatureProvider = require('eosjs/dist/eosjs-jssig').default;  // development only


const { Api, JsonRpc, RpcError } = require('eosjs');
const JsSignatureProvider = require('eosjs/dist/eosjs-jssig').default;  // development only
const { TextEncoder, TextDecoder } = require('util');

Example use

exports.transferToken = function(paramss, context) {
  console.log((paramss.amount).toPrecision(5))
  const signatureProvider = new JsSignatureProvider([context.privKey]);
  let rpc = new JsonRpc("http://jungle2.cryptolions.io:80", { fetch });
  const api = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder() });
  async function tx() {
    try {
      let resp = await api.transact({ actions: [{
          account: paramss.contract,
          name: 'transfer',
          authorization: [{
            actor: paramss.sender,
            permission: 'active',
          }],
          data: {
            from: paramss.sender,
            to: paramss.receiver,
            quantity: `${(paramss.amount).toFixed(4)} ${paramss.symbol}`,
            memo: paramss.memo,
          },
        }]
      }, {
        blocksBehind: 3,
        expireSeconds: 30,
      });
      resp = {...resp, paramss}
      console.log(resp);
        return resp
      } catch(err) {
        console.log(err)
        return err
    }
  }
  tx()
}
2
0

I got into the same error try using this import statement I hope it'll work

const { JsSignatureProvider } = require('eosjs/dist/eosjs-jssig'); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.