0

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

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

1 Answer 1

0

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 => {
    console.log(date.toNumber());
});
1
  • edit: nvm, I somehow copied it wrong. this actually works. thank you!
    – qwpeo
    Jun 29, 2018 at 13:11

Your Answer

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

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