Search code examples
nearprotocol

How to get receipts from near-api-js?


When calling a change function a function with near-api-js, how can I get the receipt of the transaction?

I've tried:

const response = await contract.changeMethod({args})
console.log(response)

But it doesn't seem to be working


Solution

  • You have to use the functionCall method on the wallet to get the receipt of the transaction.

    const response = await wallet.account().functionCall({
     contractId: 'yourContractId',
     methodName: 'changeMethod',
     args,
    })
    

    More details in this answer.