Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code does not work (syntax error) #17

Open
esigra opened this issue Apr 28, 2024 · 3 comments
Open

Example code does not work (syntax error) #17

esigra opened this issue Apr 28, 2024 · 3 comments

Comments

@esigra
Copy link

esigra commented Apr 28, 2024

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 esigra changed the title Example code does not work Example code does not work (syntax error) Apr 28, 2024
@esigra
Copy link
Author

esigra commented Apr 28, 2024

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
Copy link
Author

esigra commented Apr 29, 2024

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

@Alisgasrootuser
Copy link

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants