I do have a smart contract that has both viewMethods as well as changeMethods.
I am able to deploy the contract and we are able to successfully call both the viewmethods as well as chnagementhods.
As per near documentation whenever a function is called it return the promise.
async functionCall(contractId: string, methodName: string, args: any, gas: number, amount?: BN): Promise<FinalExecutionOutcome> {}
but when I try to get the result, it is always null.
The idea is to get transaction details from the response.
This is sample code
import * as nearAPI from "near-api-js"
import { getConfig } from './config'
async initContract() {
if (!this.contract) {
//initialize near
await this.initNear();
this.contract = await this.near.loadContract(process.env.CONTRACT_NAME, { // eslint-disable-line require-atomic-updates
// NOTE: This configuration only needed while NEAR is still in development
viewMethods: [...],
// Change methods can modify the state. But you don't receive the returned value when called.
changeMethods: [ ...."set_comments"],
// Sender is the account ID to initialize transactions.
sender: ....
});
}
return this;
}
async setComments(
id: String,
comments: String
) {
if (this.contract) {
const respone= await this.contract.set_comments(
{
id: id,
comments: comments
});
return respone;
//response is always coming as null even though the comments are updated on near
}
return null;
}
Thanks
question from:
https://stackoverflow.com/questions/65928288/trying-to-get-transacation-details-for-finalexecutionoutcome-after-calling-chang 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…