Coder Social home page Coder Social logo

如何查询余额? about tronnetcore3.1 HOT 6 OPEN

donma avatar donma commented on August 17, 2024 1
如何查询余额?

from tronnetcore3.1.

Comments (6)

miladsoft avatar miladsoft commented on August 17, 2024 3

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;

from tronnetcore3.1.

donma avatar donma commented on August 17, 2024

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

from tronnetcore3.1.

Seanxwy avatar Seanxwy commented on August 17, 2024

@donma nice

from tronnetcore3.1.

donma avatar donma commented on August 17, 2024

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

from tronnetcore3.1.

Seanxwy avatar Seanxwy commented on August 17, 2024

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

from tronnetcore3.1.

donma avatar donma commented on August 17, 2024

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

from tronnetcore3.1.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.