From df808156d008ef86fcb177d832a4947f4d35a098 Mon Sep 17 00:00:00 2001 From: sunhongtao Date: Mon, 15 Jan 2024 11:51:49 +0800 Subject: [PATCH] fix: change api for tron estimateenergy --- blockchain/service/http_handler.go | 2 +- blockchain/service/tron/tron.go | 2 +- cmd/blockchain/app.go | 2 +- cmd/blockchain/config_tron.json | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/blockchain/service/http_handler.go b/blockchain/service/http_handler.go index 959de93..859d4d3 100644 --- a/blockchain/service/http_handler.go +++ b/blockchain/service/http_handler.go @@ -414,7 +414,7 @@ func (h *HttpHandler) EstimateGasForTron(ctx *gin.Context) { return } - energy := root.Get("energy_required").Int() + energy := root.Get("energy_used").Int() h.Success(ctx, string(b), energy, ctx.Request.RequestURI) } diff --git a/blockchain/service/tron/tron.go b/blockchain/service/tron/tron.go index cd554d2..1ba3c84 100644 --- a/blockchain/service/tron/tron.go +++ b/blockchain/service/tron/tron.go @@ -163,7 +163,7 @@ func (t *Tron) EstimateGasForTron(chainCode int64, from, to, functionSelector, p "visible": true }` req = fmt.Sprintf(req, from, to, functionSelector, parameter) - res, err := t.SendReq(chainCode, req, "wallet/estimateenergy") + res, err := t.SendReq(chainCode, req, "wallet/triggerconstantcontract") if err != nil { return "", err } diff --git a/cmd/blockchain/app.go b/cmd/blockchain/app.go index ce3f0f9..dc45379 100644 --- a/cmd/blockchain/app.go +++ b/cmd/blockchain/app.go @@ -15,7 +15,7 @@ import ( func main() { var configPath string - flag.StringVar(&configPath, "blockchain", "./cmd/blockchain/config_ether.json", "The system file of config") + flag.StringVar(&configPath, "blockchain", "./cmd/blockchain/config_tron.json", "The system file of config") flag.Parse() if len(configPath) < 1 { panic("can not find config file") diff --git a/cmd/blockchain/config_tron.json b/cmd/blockchain/config_tron.json index 3726f3d..336d62b 100644 --- a/cmd/blockchain/config_tron.json +++ b/cmd/blockchain/config_tron.json @@ -9,8 +9,8 @@ }, "Nodes": [ { - "BlockChain": 205, - "NodeUrl": "http://3.225.171.164:8090", + "BlockChain": 198, + "NodeUrl": "https://api.shasta.trongrid.io", "NodeToken": "" } ]