Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contract.methods.transfer(...).send(...).on(...) is not a function #1542

Closed
honestbonsai opened this issue Apr 12, 2018 · 1 comment
Closed

Comments

@honestbonsai
Copy link

honestbonsai commented Apr 12, 2018

This is on "web3": "^1.0.0-beta.30"

So I have a helper function

const transferToken = (...) => {
  const p = contract.methods.transfer(...).send(...);
  console.log(p);
  return p;
}

transferToken(...)

p is logged as (note that on is listed as a function here):

Promise {
        _bitField: 0,
        _fulfillmentHandler0: undefined,
        _rejectionHandler0: undefined,
        _promise0: undefined,
        _receiver0: undefined,
        _trace:
         CapturedTrace {
           _parent: undefined,
           _promisesCreated: 0,
           _length: 1,
           _promiseCreated: null },
        _events:
         { transactionHash: EE { fn: [Function: bound log], context: [Circular], once: false } },
        emit: [Function: emit],
        on: [Function: on],
        once: [Function: once],
        off: [Function: removeListener],
        listeners: [Function: listeners],
        addListener: [Function: on],
        removeListener: [Function: removeListener],
        removeAllListeners: [Function: removeAllListeners] }

However if I do

const transferToken = (...) => {
  const p = contract.methods.transfer(...).send(...);
  return p;
}

const returnedP = transferToken(...)
console.log(returnedP);

returnedP logs as:

Promise { <pending> }

And I can't call returnedP.on(...). Basically the function doesn't seem to return the PromiEvent to me, instead it seems to return a pending Promise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant