I have a question about how the front end connects to the smart contract and how to call the function method of the smart contract? Is there a demo?

May 7, 2022, 5:38 AM
Hey! TON web wallet would be a good example of such application.
It uses a TonWeb, a library that has a lot of functionality to interact with the Blockchain and the contracts.
May 7, 2022, 7:31 AM
ye, I have used TonWeb.But I don't know if I connect successfully with the contract.
web3.js can call the contract method through the methods attribute, but I found through the source code that TonWen created a Contract object, and the methods attribute returned an empty object. So how should I call the function method of the smart contract?
May 7, 2022, 7:44 AM
I would suggest you to look at the contract implementations shipped with the TonWeb. There are a lot of examples. You will need to implement the Contract yourself and add the required methods to it.
Use the existing classes as a reference.
May 7, 2022, 8:09 AM
this?
So I can't directly call the methods of the contract like web3.js, and can only add the required methods through extend?
May 7, 2022, 8:14 AM
It's for Ethereum
May 7, 2022, 10:30 AM
What's the difference? ๐Ÿ˜„
May 7, 2022, 10:32 AM
https://ton.org/analysis
May 7, 2022, 10:33 AM
hi,How should I call the smart contract method? Is there a hello world Demo?
May 7, 2022, 10:53 AM
The idea is to extend the Contract class and to implement the specific behavior of your contract, yes.
May 7, 2022, 3:49 PM
sorryใ€‚ Do you have a Demo on Github? Or simple ways to invoke smart contracts like Hello World are demo. I don't know exactly how to operate, thank you๐Ÿ˜‚๐Ÿ™
May 7, 2022, 3:53 PM
We don't have such contrived examples, but the repository contains implementation for various smart contracts. You should look at them and use them as a reference.
There is a TypeScript version of the codebase, which could be easier to read.
May 7, 2022, 4:01 PM
Yes, I looked at that wallet, but it doesn't feel like what I want.
Yes, I have read the code. But according to the source code, the methods property is an empty object.
May 7, 2022, 4:10 PM
If you just need to invoke a contract get-method then you need to call this:
https://github.com/slavafomin/tonweb/blob/typescripted/src/http-provider/http-provider.ts#L266
Consider the Contract as an abstract class. It must be implemented properly, before it can be used. You will need to define your own methods in your sub-class.
Look at this for example:
https://github.com/slavafomin/tonweb/blob/typescripted/src/contract/token/nft/nft-collection.ts#L111
It's very uncommon for TON services to use TXID as transfer identification.
May 7, 2022, 6:35 PM
https://github.com/ton-defi-org/tonstarter-contracts

Thereโ€™s an example of how to call methods in the post deploy test (in build/main.deploy.ts)
May 7, 2022, 10:55 PM
https://github.com/disintar/toncli/blob/master/docs/quick_starat_guide.md
May 7, 2022, 10:57 PM
starat? ๐Ÿ˜…
May 7, 2022, 10:58 PM
๐Ÿ™ˆ
May 7, 2022, 11:00 PM

ยฉ 2024 Draquery.com All rights reserved.