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

如何查询余额? #1

Open
Seanxwy opened this issue Dec 7, 2021 · 6 comments
Open

如何查询余额? #1

Seanxwy opened this issue Dec 7, 2021 · 6 comments

Comments

@Seanxwy
Copy link

Seanxwy commented Dec 7, 2021

如何实现查询余额?以及如何查询事件呢

@miladsoft
Copy link

hi @Seanxwy

for get balance of wallet you must use this code :

            IServiceCollection services = new ServiceCollection();
            services.AddTronDotNetCore(x =>
            {
                x.Network = TronDotNetCorework.MainNet;
                x.Channel = new GrpcChannelOption { Host = "47.252.19.181", Port = 50051 };
                x.SolidityChannel = new GrpcChannelOption { Host = "47.252.19.181", Port = 50052 };
                x.ApiKey = "api-code"; //https://www.trongrid.io
            });
            services.AddLogging();

            var service = services.BuildServiceProvider();
            var walletClient = service.GetService<IWalletClient>();

            var account = walletClient.GetAccount(privatekey);

            //USDT TOKEN
            var contractAddress = "TXLAQ63Xg1NAzckPwKHvzw7CSEmLMEqcdj";


            var contractClientFactory = service.GetService<IContractClientFactory>();

            var contractClient = contractClientFactory.CreateClient(ContractProtocol.TRC20);

            var result = contractClient.BalanceOfAsync(contractAddress, account).Result;

@donma
Copy link
Owner

donma commented Feb 18, 2022

if u need get USDT balance in new wallet .

u can reference this blog post

https://blog.no2don.com/2022/01/c-tron-usdt.html

@Seanxwy
Copy link
Author

Seanxwy commented Feb 18, 2022

@donma nice

@donma
Copy link
Owner

donma commented Feb 18, 2022

你說的事件是指錢包發生有入帳的事件嗎?
如果是這樣你不是節點應該是無法,你要一直去監聽
除非你是節點,節點就會有自己的事件

@Seanxwy
Copy link
Author

Seanxwy commented Feb 18, 2022

不是节点,使用定时监听的方式也应该可以达成需求吧。

@donma
Copy link
Owner

donma commented Feb 18, 2022

對阿 簡單的說就是你要一直去查

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

3 participants