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

Get recent transactions for an account #47

Open
davidcanar opened this issue Apr 6, 2023 · 4 comments
Open

Get recent transactions for an account #47

davidcanar opened this issue Apr 6, 2023 · 4 comments

Comments

@davidcanar
Copy link

How to get the last transactions for an account? I'm trying to check if a payment posted I would like a list of the transactions for an account. I haven't been able to figure out how to.

@devfxplayer
Copy link

same here

@davidcanar
Copy link
Author

I found the raw REST API function and that is what I'm using right now. I still haven't found the way to do it with this library:

var apiUrl = "https://api.trongrid.io";
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("TRON-PRO-API-KEY", key);
var data = await httpClient.GetStringAsync($"{apiUrl}/v1/accounts/{address}/transactions/trc20");

@Davelhw
Copy link

Davelhw commented Apr 23, 2023

install RestSharp:
dotnet add package RestSharp

Sample:
var client = new RestClient("https://api.shasta.trongrid.io/v1/accounts/{your wallet}/transactions");
var request = new RestRequest();
request.AddHeader("accept", "application/json");
IRestResponse response = client.Execute(request);

@stoway
Copy link
Owner

stoway commented May 18, 2023

you could use grpc protocol,
reference sample:

        public async Task<Protocol.BlockExtention> GetBlockByNumAsync(long blockNumber)
        {
            var wallet = _walletClient.GetWallet();
            var result = await wallet.GetBlockByNum2Async(new Protocol.NumberMessage { Num = blockNumber }, headers: _walletClient.GetHeaders());
            return result;
        }
        public async Task<long> GetBlockByLatestNumAsync()
        {
            var client = new HttpClient();
            var url = $"{_options.Value.ApiUrl}/walletsolidity/getnowblock";
            client.DefaultRequestHeaders.Add("TRON-PRO-API-KEY", _options.Value.ApiKey);
            var json = await client.GetStringAsync(url);

            var result = System.Text.Json.JsonSerializer.Deserialize<SolidityLatestBlockNumber>(json);

            //var wallet = _walletClient.GetWallet();
            //var result = await wallet.GetNowBlock2Async(new Protocol.EmptyMessage());
            return result.BlockHeader.RawData.Number;
        }

tron's api document: https://developers.tron.network/reference/background

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

4 participants