i created a variable called startDate using now in a smart contract.

when reading it using Contract.startDate() it returns BigNumber { s: 1, e: 9, c: [ 1530272788 ] }

how do i convert this to an Interger (or anything else i can work with)? toNumber() and toString() wont work.

edit: toNumber() already worked on "bigger" bugnumbers (with e>10), just not with the bigNumber returned by startDate

  • Try valueOf() or toString() . – Henk Jun 29 '18 at 12:21
  • already said toString() doesnt work. returns '[object Promise]' valueOf() returns the same BigNumber again – qwpeo Jun 29 '18 at 12:26

toNumber() is right, but it sounds like you have a Promise that will resolve to a BigNumber. If so, this should work:

Contract.startDate().then(date => {
  • edit: nvm, I somehow copied it wrong. this actually works. thank you! – qwpeo Jun 29 '18 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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