# encodeUint64(asset\_id) doesn't work

**URL:** https://forum.algorand.co/t/encodeuint64-asset-id-doesnt-work/8572
**Category:** General
**Created:** [December 21, 2022, 9:39am UTC](https://forum.algorand.co/t/encodeuint64-asset-id-doesnt-work/8572 "2022-12-21T09:39:04Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![salman.haider](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@salman.haider](https://forum.algorand.co/u/salman.haider)
#### Post date: [December 21, 2022, 9:39am UTC](https://forum.algorand.co/t/encodeuint64-asset-id-doesnt-work/8572/1 "2022-12-21T09:39:04Z")

</div>

I’m trying to push the assetID to app.Args by encoding it to uint64 but its giving error

> console.log(algosdk.encodeUint64(12345))

It was working fine recently but now it giving issues.

```auto

uint64.ts:17 Uncaught TypeError: buf.writeBigUInt64BE is not a function
    at Module.encodeUint64 (uint64.ts:17:1)
    at App.tsx:16:1
    at invokePassiveEffectCreate (react-dom.development.js:23487:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at flushPassiveEffectsImpl (react-dom.development.js:23574:1)
    at unstable_runWithPriority (scheduler.development.js:468:1)
    at runWithPriority$1 (react-dom.development.js:11276:1)
    at flushPassiveEffects (react-dom.development.js:23447:1)
    at react-dom.development.js:23324:1
    at workLoop (scheduler.development.js:417:1)
    at flushWork (scheduler.development.js:390:1)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:157:1)

```

---

<div class="post-metadata">

### Author: ![scholtz](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.algorand.co/scholtz/32/864_2.png) [@scholtz](https://forum.algorand.co/u/scholtz)
#### Post date: [December 21, 2022, 9:47am UTC](https://forum.algorand.co/t/encodeuint64-asset-id-doesnt-work/8572/2 "2022-12-21T09:47:03Z")

</div>

i am using algosdk 1.24.1 without any issue…

`appArgs.push(algosdk.encodeUint64(123));` works for me well…

you probably installed some dependency which downgraded/changed buffer library?

---

<div class="post-metadata">

### Author: ![salman.haider](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@salman.haider](https://forum.algorand.co/u/salman.haider)
#### Post date: [December 21, 2022, 2:03pm UTC](https://forum.algorand.co/t/encodeuint64-asset-id-doesnt-work/8572/3 "2022-12-21T14:03:11Z")

</div>

I did use this version just 2 minutes ago and still got same error

---

<div class="post-metadata">

### Author: ![fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@fabrice](https://forum.algorand.co/u/fabrice)
#### Post date: [December 21, 2022, 3:10pm UTC](https://forum.algorand.co/t/encodeuint64-asset-id-doesnt-work/8572/4 "2022-12-21T15:10:07Z")

</div>

Which version of node JS and algosdk are you using?  
Are you using browserify or similar?  
You may need to upgrade some of those.

---

<div class="post-metadata">

### Author: ![salman.haider](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@salman.haider](https://forum.algorand.co/u/salman.haider)
#### Post date: [December 21, 2022, 7:05pm UTC](https://forum.algorand.co/t/encodeuint64-asset-id-doesnt-work/8572/5 "2022-12-21T19:05:10Z")

</div>

node 14.17.0 and algosdk 1.24.1

---

<div class="post-metadata">

### Author: ![scholtz](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.algorand.co/scholtz/32/864_2.png) [@scholtz](https://forum.algorand.co/u/scholtz)
#### Post date: [December 21, 2022, 8:30pm UTC](https://forum.algorand.co/t/encodeuint64-asset-id-doesnt-work/8572/6 "2022-12-21T20:30:41Z")

</div>

i am using node v16.18.1 …

---

<div class="post-metadata">

### Author: ![fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@fabrice](https://forum.algorand.co/u/fabrice)
#### Post date: [December 21, 2022, 10:28pm UTC](https://forum.algorand.co/t/encodeuint64-asset-id-doesnt-work/8572/7 "2022-12-21T22:28:00Z")

</div>

It looks like node v14.10 or after should work as this function was added in v14.10:  
[https://nodejs.org/api/buffer.html#bufwritebiguint64bevalue-offset](https://nodejs.org/api/buffer.html#bufwritebiguint64bevalue-offset)

So my guess is that you’re using a framework/toolchain that is somewhat not providing this function.  
It looks you are using react, but which toolchain are you using:  
create react app, next.js, gatsby, vite  
?  
Which version?

Maybe posting package.json may help.

---

<div class="post-metadata">

### Author: ![AnishRane](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@AnishRane](https://forum.algorand.co/u/AnishRane)
#### Post date: [January 5, 2023, 9:29am UTC](https://forum.algorand.co/t/encodeuint64-asset-id-doesnt-work/8572/8 "2023-01-05T09:29:13Z")

</div>

@fabrice I am also facing same issue with algosdk 1.24.1 and node version 18.12.1, getting error on algosdk.encodeUint64() method

---

<div class="post-metadata">

### Author: ![scholtz](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.algorand.co/scholtz/32/864_2.png) [@scholtz](https://forum.algorand.co/u/scholtz)
#### Post date: [January 5, 2023, 10:03am UTC](https://forum.algorand.co/t/encodeuint64-asset-id-doesnt-work/8572/9 "2023-01-05T10:03:37Z")

</div>

i suggest to put this into your test cases

```auto
  it("encodeUint64", function () {
    expect(Buffer.from(algosdk.encodeUint64(123)).toString("hex")).toBe("000000000000007b");
    expect(Buffer.from(algosdk.encodeUint64(123123123123123)).toString("hex")).toBe("00006ffad60473b3");
  });

```

if it fails, there is issue with algosdk or some dependencies… if it goes through the issue is somewhere else

---

<div class="post-metadata">

### Author: ![fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@fabrice](https://forum.algorand.co/u/fabrice)
#### Post date: [January 5, 2023, 2:07pm UTC](https://forum.algorand.co/t/encodeuint64-asset-id-doesnt-work/8572/10 "2023-01-05T14:07:31Z")

</div>

Can you show the exact error?  
Are you using a framework such as create-react-app, next.js, gatsby, vite…?  
Can you try to add the test suggested by @scholtz above?  
Can you post your package.json (e.g., in Github gist)?  
Can you create a fresh project with only algosdk and an `index.js` file that just test `encodeUint64` and nothing else?
