Impossible to send custom tokens with NodeJS SDK v2

Hello,

Thanks for this new forum category :wink:

I’m trying to send custom tokens by using the NodeJS SDK v2 and it doesn’t work.

Here is my code.

When I use master branch of the SDK v2, I get:

//token
t {
  accountKeySet: t {
    ...
  },
  tokenId: '240a1f3d00b3c6027ebbdac4203823ceb56e6813afa53d122a0c28ba59262397',
  name: 'Incscan Token',
  symbol: 'INCSCAN',
  totalSupply: '0',
  isPrivacyToken: true,
  bridgeInfo: undefined
}
//balance
Token total balance 10
//transfer
[Error]2020-12-13T07:05:29.195Z - Privacy token 240a1f3d00b3c6027ebbdac4203823ceb56e6813afa53d122a0c28ba59262397 transfered failed (Unexpected token u in JSON at position 0)
(node:64265) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at e.<anonymous> (/Users/charles/Workspace/token-distribution/node_modules/incognito-js/build/node/index.js:2:824616)
    at /Users/charles/Workspace/token-distribution/node_modules/incognito-js/build/node/index.js:2:823324
    at Object.next (/Users/charles/Workspace/token-distribution/node_modules/incognito-js/build/node/index.js:2:823429)
    at s (/Users/charles/Workspace/token-distribution/node_modules/incognito-js/build/node/index.js:2:822142)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)

When I use develop branch fo the SDK v2, I get:

//token
[Warning]2020-12-13T07:14:27.938Z - Can not find token with id 240a1f3d00b3c6027ebbdac4203823ceb56e6813afa53d122a0c28ba59262397
undefined

Let me transfer this to our devs for help :slight_smile:

2 Likes

Hi, the sdk-v2 is not complete. You can use branch #develop to fix this problem by
yarn add https://github.com/incognitochain/sdk-v2#develop
and follow ex at file
https://github.com/incognitochain/sdk-v2/blob/master/sample/test-node.js

Hi @jayce-incognito,

Thanks for your answer. Unfortunately, as I said in my first message, it doesn’t work with develop branch of the sdk-v2.

image
Can you get privacy token data base on file test-node.js?
I call api https://api-staging.incognito.org/pcustomtoken/list and can not found any token has Id
‘240a1f3d00b3c6027ebbdac4203823ceb56e6813afa53d122a0c28ba59262397’

@jayce-incognito Btw, related to this :slight_smile: Should someone answer this? We just request the generator scripts for both ptoken/list and pcustomtoken/list?

Thanks.

I’ll consider it. Now I’m call api same as sdk too :smiley:

It’s a mainnet token, that’s why it doesn’t work on your side.

About the issue, I think it’s related to build/node folder.
In my project, If I use the build/node directory provided by yarn add https://github.com/incognitochain/sdk-v2#develop, it doesn’t work.

If I checkout sdk-v2 (develop branch), run yarn build:node and copy the content of build/node inside my project (in node_modules/incognito-js/build/node), it works.

1 Like

I exclude folder and script build/node to decrease time build for web browser. Let me update it again

1 Like

Hi @jayce-incognito,

It’s ok on my side after you removed build/node folder from .gitignore file :+1: