Comments (7)
For master chain yes, it is constants
from tonutils-go.
Hi, you could use GetBlockTransactionsV2
method. Usage example can be found in block-scan.
from tonutils-go.
In TON, there could be many parallel blocks in the same time because of sharding. In block-scan example we taking latest masterchain block (and each next when available), then getting basechain shard blocks related to master block and getting transactions for each shard block.
from tonutils-go.
Hi, I've tried and follow your block-scan. It works for new blocks and new shards. but what exact i'm trying to find is scan transactions in the past of a block. you can follow this url for example:
https://tonwhales.com/explorer/block/30283112
from tonutils-go.
Prepared example for you, it is doing what you need:
func main() {
client := liteclient.NewConnectionPool()
// connect to mainnet lite servers
err := client.AddConnectionsFromConfigUrl(context.Background(), "https://ton-blockchain.github.io/global.config.json")
if err != nil {
log.Fatalln("connection err: ", err.Error())
return
}
// initialize ton api lite connection wrapper
api := ton.NewAPIClient(client)
// find master block
master, err := api.LookupBlock(context.Background(), -1, -0x8000000000000000, 30283112)
if err != nil {
log.Fatalln("get masterchain info err: ", err.Error())
return
}
// find it's shard blocks
currentShards, err := api.GetBlockShardsInfo(context.Background(), master)
if err != nil {
log.Fatalln("get shards err:", err.Error())
return
}
// we also want to see master block transactions
currentShards = append(currentShards, master)
for _, shard := range currentShards {
var fetchedIDs []ton.TransactionShortInfo
var after *ton.TransactionID3
var more = true
// load all transactions in batches with 100 transactions in each while exists
for more {
fetchedIDs, more, err = api.GetBlockTransactionsV2(context.Background(), shard, 100, after)
if err != nil {
log.Fatalln("get tx ids err:", err.Error())
return
}
if more {
// set load offset for next query (pagination)
after = fetchedIDs[len(fetchedIDs)-1].ID3()
}
for _, id := range fetchedIDs {
// get full transaction by id
tx, err := api.GetTransaction(context.Background(), shard, address.NewAddress(0, byte(shard.Workchain), id.Account), id.LT)
if err != nil {
log.Fatalln("get tx data err:", err.Error())
return
}
log.Println(tx.String())
}
}
}
}
from tonutils-go.
Thank you so much for answering my question so quickly. but let me ask about shard and workchain when calling LookupBlock function. Is that the default set value and will it always be? workchain=-1 and shard=. -0x8000000000000000
from tonutils-go.
great. so that I just need to change seqno to scan another blocks from your example right?
from tonutils-go.
Related Issues (20)
- how can i get one transcation info by hash? HOT 3
- i only want use GetTransaction method get one transcation by address+lt,please give me use this method demo.thank you HOT 5
- Accessing validator-engine-console with ADNL client HOT 3
- ListTransactions() always fail with -400 error HOT 1
- How to transfer jettons from subwallets using highload wallet? HOT 2
- Issue sending JETTON USDT - "failed to run get_wallet_address method: contract exit code: -256 (contract is not initialized)" HOT 2
- 如何设置excess地址 HOT 3
- Question about BuildTransferPayload HOT 2
- 如何判断用户有没有打USDT进后端账户,怎么监听支付消息呢? HOT 1
- how to get jetton USDT transfer detail by transaction hash? HOT 1
- Just want build a boc HOT 2
- Send jetton with comment failed HOT 1
- jetton comment cannot be parsed HOT 2
- api.SubscribeOnTransactions cannot monitor transactions with ton transfer 0 HOT 4
- Out message list can be nil in FindLastTransactionByOutMsgHash HOT 1
- findLastTransactionByHash does not work as expected HOT 3
- Highload wallet V3 computes wrong wallet address HOT 3
- How to use `tlb` struct tag to load string snake? HOT 1
- send jetton failed HOT 4
- return tx after Transfer HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tonutils-go.