Accountid和PublicKey返回0.0.1261794的不同交易记录
创始人
2024-07-23 03:31:34
0

这是因为在Hedera网络中,一个账户可以有多个公钥,每个公钥都可以进行交易。如果使用不同的公钥查询交易记录,将会返回不同的结果。要解决这个问题,可以通过查询指定公钥的交易历史记录来获得正确的结果。下面提供一个Java代码示例:

import com.hedera.hashgraph.sdk.*;
import io.github.cdimascio.dotenv.Dotenv;

public class GetAccountTransactions {
    public static void main(String[] args) {
        // Load the Hedera network configuration from the .env file
        Dotenv dotenv = Dotenv.load();

        // Grab the account ID and public key from the .env file
        AccountId accountId = AccountId.fromString(dotenv.get("ACCOUNT_ID"));
        Ed25519PublicKey publicKey = Ed25519PublicKey.fromString(dotenv.get("PUBLIC_KEY"));

        // Create the Hedera client and get the account transactions using the specified public key
        Client client = Client.forTestnet();
        AccountRecordsQuery accountRecordsQuery = new AccountRecordsQuery().setAccountId(accountId).setPublicKey(publicKey);
        try {
            AccountRecordsQueryResponse response = accountRecordsQuery.execute(client);
            // Iterate over the transaction records and do something with them
            for (TransactionRecord record : response.getRecords()) {
                // Do something with the transaction record
            }
        } catch (HederaStatusException e) {
            System.out.println("Error getting account transactions: " + e.getMessage());
        } finally {
            client.close();
        }
    }
}

相关内容

热门资讯

oppo手机安卓系统换成苹果系... OPPO手机安卓系统换成苹果系统:现实吗?如何操作?随着智能手机市场的不断发展,用户对于手机系统的需...
安卓系统怎么连不上carlif... 安卓系统无法连接CarLife的原因及解决方法随着智能手机的普及,CarLife这一车载互联功能为驾...
iwatch怎么连接安卓系统,... 你有没有想过,那款时尚又实用的iWatch,竟然只能和iPhone好上好?别急,今天就来给你揭秘,怎...
iphone系统与安卓系统更新... 最近是不是你也遇到了这样的烦恼?手机更新系统总是失败,急得你团团转。别急,今天就来给你揭秘为什么iP...
安卓平板改windows 系统... 你有没有想过,你的安卓平板电脑是不是也能变身成Windows系统的超级英雄呢?想象在同一个设备上,你...
安卓系统连接耳机模式,蓝牙、有... 亲爱的手机控们,你们有没有遇到过这种情况:手机突然变成了“耳机模式”,明明耳机没插,声音却只从耳机孔...
安卓系统上滑按键,便捷生活与高... 你有没有发现,现在手机屏幕越来越大,操作起来却越来越方便了呢?这都得归功于安卓系统上的那些神奇的上滑...
安装了Anaconda之后找不... 在安装Anaconda后,如果找不到Jupyter Notebook,可以尝试以下解决方法:检查环境...
希沃系统怎么装安卓系统,解锁更... 亲爱的读者们,你是否也像我一样,对希沃一体机上的安卓系统充满了好奇呢?想象在教室里,你的希沃一体机不...
荣耀鸿蒙系统转安卓,操作指南与... 荣耀鸿蒙系统转安卓:操作指南与注意事项一、荣耀鸿蒙系统转安卓的可行性首先,我们需要明确一点,荣耀鸿蒙...