You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In TON there are shards. And knowing only address we can't find out the shard on which this contract exists. So we have to try each shard by running contract's method.
for_, s:=rangeshards {
ifresult, err=client.RunGetMethod(context.Background(), s, addr, function, params...); err!=nil {
log.Info().Msg(err.Error())
continue// If there are a lot of shards the contract doesn't exists in a shard // HOWEVER contract could might not exist
} else {
break
}
}
However, using your package it's hard to distinguish causes of errors:
{"level":"info","time":"2024-12-27T00:48:34+05:00","message":"lite server error, code -400: requested account id is not contained in the shard of the reference block"}
{"level":"info","time":"2024-12-27T00:49:50+05:00","message":"contract exit code: 11"}
Do I have to parse the string to get rc or lite server error?
Possible solution
In Go error is an interface:
// The error built-in interface type is the conventional interface for// representing an error condition, with the nil value representing no error.typeerrorinterface {
Error() string
}
Hi, you can just pass master block to RunGetMethod instead of shard block, LS will map shard block automatically according to reference in master block.
If you still need to know shard, it can be calculated based on address, first bits of address hash part will indicate shard, there is a method exists for that
Problem
In TON there are shards. And knowing only address we can't find out the shard on which this contract exists. So we have to try each shard by running contract's method.
However, using your package it's hard to distinguish causes of errors:
Do I have to parse the string to get rc or lite server error?
Possible solution
In Go
error
is an interface:So it's better to create a batch of constants:
And overload interface:
It's a simple example that can clarify all errors in you project and shall help others to handle them
The text was updated successfully, but these errors were encountered: