Open esigra opened 2 months ago
The following code almost works (it hangs at the end, don't know how to fix it):
import {Address, Cell, TonClient} from "@ton/ton";
import {SmartContract} from "ton-contract-executor";
const contractAddress = Address.parse('EQD4FPq-PRDieyQKkizFTRtSDyucUIqrj0v_zXJmqaDp6_0t')
const client = new TonClient({
endpoint: 'https://toncenter.com/api/v2/jsonRPC'
})
const state = await client.getContractState(contractAddress)
const code = Cell.fromBoc(state.code)[0]
const data = Cell.fromBoc(state.data)[0]
const contract = await SmartContract.fromCell(code, data)
const res = await contract.invokeGetMethod('seqno', [])
console.log(res)
Found how to not hang at the end: TvmRunnerAsynchronous.getShared().cleanup()
Getter function in Tact syntax for example get fun sum(a: Int, b: Int): Int { return a + b; } get fun and(a: Bool, b: Bool): Bool { return a && b; } get fun answer(a: Int): String { let sb: StringBuilder = beginString(); sb.append("The meaning of life is "); sb.append(a.toString()); return sb.toString(); } Can only pass int type? Why is there an error in the address type? for example get fun getBalance(adr:Address) :Int { //Check the user's balance return 0; } Unable to execute get method. Got exit_code:
The example code at https://github.com/ton-community/ton-contract-executor does not work: