Last active
February 19, 2025 07:04
-
-
Save donma/f7db0ea1d991f22663197e39e4028547 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ContractTransactionResponse | |
| { | |
| public List<Datum> data { get; set; } | |
| public bool success { get; set; } | |
| public Meta meta { get; set; } | |
| public class Datum | |
| { | |
| public List<Ret> ret { get; set; } | |
| public List<string> signature { get; set; } | |
| public string txID { get; set; } | |
| public int net_usage { get; set; } | |
| public string raw_data_hex { get; set; } | |
| public int net_fee { get; set; } | |
| public int energy_usage { get; set; } | |
| public string block_timestamp { get; set; } | |
| public string blockNumber { get; set; } | |
| public int energy_fee { get; set; } | |
| public int energy_usage_total { get; set; } | |
| public RawData raw_data { get; set; } | |
| public List<object> internal_transactions { get; set; } | |
| public class Ret | |
| { | |
| public string contractRet { get; set; } | |
| } | |
| public class RawData | |
| { | |
| public List<Contract> contract { get; set; } | |
| public string ref_block_bytes { get; set; } | |
| public string ref_block_hash { get; set; } | |
| public object expiration { get; set; } | |
| public int fee_limit { get; set; } | |
| public object timestamp { get; set; } | |
| public class Contract | |
| { | |
| public Parameter parameter { get; set; } | |
| public string type { get; set; } | |
| public class Parameter | |
| { | |
| public Value value { get; set; } | |
| public string type_url { get; set; } | |
| public class Value | |
| { | |
| public string data { get; set; } | |
| public string owner_address { get; set; } | |
| public string contract_address { get; set; } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| public class Meta | |
| { | |
| public long at { get; set; } | |
| public string fingerprint { get; set; } | |
| public Links links { get; set; } | |
| public int page_size { get; set; } | |
| public class Links | |
| { | |
| public string next { get; set; } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // USDT ADDRESS | |
| GetContractTransactions("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"); | |
| /// <summary> | |
| /// 取得 Contract Transactions | |
| /// </summary> | |
| /// <param name="contractAddress">Contract Address</param> | |
| static void GetContractTransactions(string contractAddress) | |
| { | |
| var client = new RestClient("https://api.trongrid.io/v1/contracts/" + contractAddress + "/transactions"); | |
| var request = new RestRequest("",Method.Get); | |
| request.AddHeader("accept", "application/json"); | |
| var response = client.Execute(request); | |
| var contractTransObj = JsonConvert.DeserializeObject<ContractTransactionResponse>(response.Content); | |
| foreach (var t in contractTransObj.data) { | |
| ////最後64位就是金額 | |
| var amount = | |
| BigInteger.Parse(t.raw_data.contract[0].parameter.value.data.Substring(t.raw_data.contract[0].parameter.value.data.Length - 64, 64), NumberStyles.AllowHexSpecifier); | |
| var to = ConvertHexToBase58Check("41" + (t.raw_data.contract[0].parameter.value.data.Substring(32, 40))); // 取後 20 bytes | |
| var from = ConvertHexToBase58Check((t.raw_data.contract[0].parameter.value.owner_address)); // 取後 20 bytes | |
| Console.WriteLine("Block:"+t.blockNumber+", txid:"+t.txID+", from:"+ from + ", to:"+to +" ,amount:"+ amount); | |
| } | |
| // Console.WriteLine(response.Content); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment