# Failed to execute script at block

**URL:** <https://forum.flow.com/t/failed-to-execute-script-at-block/2234>\
**Category:** Flow JavaScript SDK\
**Tags:** flow-sdk-js\
**Created:** [July 26, 2021, 9:11am UTC](https://forum.flow.com/t/failed-to-execute-script-at-block/2234 "2021-07-26T09:11:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shadyr6](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@shadyr6](https://forum.flow.com/u/shadyr6)\
**Post date:** [July 26, 2021, 9:11am UTC](https://forum.flow.com/t/failed-to-execute-script-at-block/2234/1 "2021-07-26T09:11:36Z")

</div>

import \* as fcl from “@onflow/fcl”;

import \* as t from “@onflow/types”;

export const LatestListing = async () =\> {

```
const script = `import NFTStorefront from 0x4fc019cea9fc4817

pub fun main(set : UInt64) : [UInt64]{

    var end = UInt64(0)

    var n = UInt64(NFTStorefront.allIdsForTimeStamps.length - 1)

    var start = n - ((set-1) * 10)

    if n >= set*10 {

        end = n - (set *10) + 1

    } else {

        end = start - n%10

    }

    

    let timearr : [UInt64] = []

    

    while start >= end {

        timearr.append(NFTStorefront.allIdsForTimeStamps[start])

        if start == 0 {

            break

        }

        start = start - 1 

    }

    

    return timearr;

}`

try {

    const response = await fcl.send([

        fcl.script`${script}`,

        fcl.args([

            fcl.arg(1, t.UInt64)

        ]),

        fcl.limit(100)

    ])

    console.log("res", await fcl.decode(response))

    return await fcl.decode(response)

} catch (e) {

    console.log('error', e)

}

```

}

this is giving an error  
rpc error: code = Internal desc = failed to execute script: failed to execute script at block (e5e930e498c0fa0e48eca89fd01c7022d656d5ec4be6c97b14e9859447bd0a58): [Error Code: 1101] cadence runtime error Execution failed:  
error: underflow

I am using testnet.  
Please help

---

<div class="post-metadata">

**Author:** ![flowjosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/flowjosh/32/362_2.png) [@flowjosh](https://forum.flow.com/u/flowjosh)\
**Post date:** [July 30, 2021, 4:15pm UTC](https://forum.flow.com/t/failed-to-execute-script-at-block/2234/2 "2021-07-30T16:15:19Z")

</div>

It looks like you have an underflow somewhere, which means that you are trying to create a number that is below the minimum representation for the type you are using (`UInt64`). I would take a look at your arithmetic operations to make sure that is happening, or if you intend to have a negative number, use `Int64` instead.
