ton-community / ton-contract-executor

The TON Contract Executor allows you to write, debug, and fully test your contracts before launching them to the TON blockchain.
64 stars 11 forks source link

Example code does not work (syntax error) #17

Open esigra opened 2 months ago

esigra commented 2 months ago

The example code at https://github.com/ton-community/ton-contract-executor does not work:

    let code = Cell.fromBoc(state.code!)[0]
                                  ^^^^

SyntaxError: missing ) after argument list
esigra commented 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)
esigra commented 2 months ago

Found how to not hang at the end: TvmRunnerAsynchronous.getShared().cleanup()

Alisgasrootuser commented 1 week ago

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: