Giter VIP home page Giter VIP logo

Comments (6)

amgando avatar amgando commented on September 24, 2024

problem

unable to complete cross contract call tutorial due to upper limit on size of number that can be passed to a smart contract function call via nearlib

detail

recently @evgenykuzyakov submitted to Slack #general (see line 72 in main.js) an example of increasing the amount of gas submitted to 9.9 NEAR when invoking a function call. This seems to work find as a passthrough value since no checks are made in nearlib on the size of the number, it goes directly to nearcore. The example works fine.

But since we're using BN.js in nearlib we're limited by this assertion:
assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)

This line limits us to
9007199254740991, which is much smaller than
99000000000000000000 suggested by the working example linked above.

Transaction 6fci1ciicWLM7JFcdZVDWaDXtJpzMScvvA6GmEuLPTZc failed. Exceeded the prepaid gas

reproduction

  • open https://studio.nearprotocol.com/?f=7cd5vk11b

  • run the test

  • note error Transaction failed. Exceeded the prepaid gas.

  • edit the value in src/test.js line 36 by incrementing the gas passed as an argument to contract.calculate() from
    9007199254740991 to
    9007199254740992

  • run the test

  • note error Error: Assertion failed coming from the assertion on this line in BN.js (one of our nearlib dependencies, line 3204)

Error: Assertion failed
    at assert (https://cdn.jsdelivr.net/npm/[email protected]/dist/nearlib.js:3082:21)
    at BN._initNumber (https://cdn.jsdelivr.net/npm/[email protected]/dist/nearlib.js:3204:7)

from near-api-js.

kcole16 avatar kcole16 commented on September 24, 2024

@bowenwang1996 Is the max amount of gas allowed for function calls a constant?

from near-api-js.

bowenwang1996 avatar bowenwang1996 commented on September 24, 2024

yes

from near-api-js.

vgrichina avatar vgrichina commented on September 24, 2024

@amgando

But since we're using BN.js in nearlib we're limited by this assertion:
assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)

we aren't, just need to pass number as decimal string, i.e. new BN("99000000000000000000")

from near-api-js.

amgando avatar amgando commented on September 24, 2024

we aren't, just need to pass number as decimal string, i.e. new BN("99000000000000000000")

@vgrichina oh jeez πŸ€¦β€β™‚

from near-api-js.

amgando avatar amgando commented on September 24, 2024

@vgrichina -- just thinking about this again now. BN is available in a JS context but this number is being passed to ContractPromise.create in an AssemblyScript context. unfortunately i'll have to revisit this more carefully after retracing my steps since I couldn't easily reproduce the problem I experienced before

from near-api-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.