[Solved] NdeJS SDK transfer() problem

Hello guys!

I have a little problem with NodeJS SDK and it seems to me that it is a bug.
I am not doing anything special, just sending native token like that:

let transferTransactionResponse = await nativeToken.transfer(
    {
        paymentInfoList: [
            {
                paymentAddressStr: recipientAddress,
                amount: amount.toString(),
                message: ''
            }
        ],
        nativeFee: nativeFee.toString()
    }
)

The code that I have mentioned is triggered by a POST endpoint:

app.post('/transactions', async (req, res) => {
    res.json(
        await transactionsModule.transferTransaction(
            req.body.sender_address, req.body.recipient_address, req.body.amount
        )
    )
})

The transaction is being sent successfully, the balances of sender and recipient wallets are being changed as well and a response with 200 status is being returned.
But the problem occurs AFTER the response is returned (after app.post is being executed) and I am getting the following error:

(node:31258) UnhandledPromiseRejectionWarning: TypeError: this.getMethod is not a function
    at e.<anonymous> (/home/alex/mars_project/incognito_transaction_anonymizer/node_modules/incognito-js/build/node/index.js:2:885487)
    at /home/alex/mars_project/incognito_transaction_anonymizer/node_modules/incognito-js/build/node/index.js:2:884256
    at Object.next (/home/alex/mars_project/incognito_transaction_anonymizer/node_modules/incognito-js/build/node/index.js:2:884361)
    at /home/alex/mars_project/incognito_transaction_anonymizer/node_modules/incognito-js/build/node/index.js:2:883272
    at new Promise (<anonymous>)
    at n (/home/alex/mars_project/incognito_transaction_anonymizer/node_modules/incognito-js/build/node/index.js:2:883017)
    at e.get (/home/alex/mars_project/incognito_transaction_anonymizer/node_modules/incognito-js/build/node/index.js:2:885340)
    at /home/alex/mars_project/incognito_transaction_anonymizer/node_modules/incognito-js/build/node/index.js:2:679152
    at /home/alex/mars_project/incognito_transaction_anonymizer/node_modules/incognito-js/build/node/index.js:2:678725
    at Object.next (/home/alex/mars_project/incognito_transaction_anonymizer/node_modules/incognito-js/build/node/index.js:2:678830)
(node:31258) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:31258) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Does anyone know what can cause the issue? Maybe I am doing something wronrg/ Or is it an SDK bug?

1 Like

The root cause of the issue is that you haven’t implement storage service for the SDK so after you had sent your transaction, SDK couldn’t store the history. If you don’t need to store the history anywhere you can ignore storage service like this.

incognito.storageService.implement({
    setMethod: () => null,
    getMethod: () => null,
    removeMethod: () => null,
});
2 Likes

Thank you!

1 Like