我已经发现,我可以获取合约的交易,在该示例中为 51:https://etherscan.io/address/0x2d8b6fc9ae0fa508caa14453ce13acb8d906c184
我可以通过以下 api 调用获取此信息 - 这不是我想要的,因为这为我提供了合约的交易: https://api.etherscan.io/api?module=account&action=txlist&address=0x2d8b6fc9ae0fa508caa14453ce13acb8d906c184&apikey=...
我通过moralis API找到了一个解决方案(免费版本,最多40k CU/天)- C#代码:
const string CURSOR_SUFFIX = @"&cursor=";
const string GET_TRANSACTIONS_P = @"https://deep-index.moralis.io/api/v2.2/erc20/";
const string GET_TRANSACTIONS_S = @"/transfers?chain=eth&order=ASC&limit=100";
private async Task<JsonResult> getTransactionPageForToken(string pContractAddress, string pCursor)
{
JsonResult jrTokenTransactions;
string sUrl = GET_TRANSACTIONS_P + pContractAddress + GET_TRANSACTIONS_S;
if (pCursor != string.Empty)
{
sUrl += CURSOR_SUFFIX + pCursor;
}
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("X-API-Key", API_KEY_TOKEN);
var response = await client.GetAsync(sUrl);
response.EnsureSuccessStatusCode();
string sContent = await response.Content.ReadAsStringAsync();
jrTokenTransactions = JsonConvert.DeserializeObject<JsonResult>(sContent);
Console.WriteLine(sContent);
}
return jrTokenTransactions;
}