アカウントに関連するトランザクションの完全なリストの取得
入門セクション を完了している
新しくファイルを開いて、アカウントアドレスを定義します。
// replace with account address
const rawAddress = 'TCHBDE-NCLKEB-ILBPWP-3JPB2X-NY64OE-7PYHHE-32I';
const address = Address.createFromRawAddress(rawAddress);
// replace with account address
const rawAddress = 'TCHBDE-NCLKEB-ILBPWP-3JPB2X-NY64OE-7PYHHE-32I';
const address = symbol_sdk_1.Address.createFromRawAddress(rawAddress);
// replace with signer public key
NetworkType networkType = repositoryFactory.getNetworkType().toFuture().get();
PublicAccount signer = PublicAccount.createFromPublicKey(
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
networkType);
2. Define a new TransactionHttp
repository and the search criteria.
In this example, we will retrieve all account-related transactions with at least one confirmation, but you could also query the unconfirmed and partial collections.
// replace with node endpoint
const nodeUrl = 'NODE_URL';
const repositoryFactory = new RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();
const searchCriteria = {
group: TransactionGroup.Confirmed,
address,
pageNumber: 1,
pageSize: 100,
};
transactionHttp.search(searchCriteria).subscribe(
(page) => console.log(page.data),
(err) => console.error(err),
);
// replace with node endpoint
const nodeUrl = 'NODE_URL';
const repositoryFactory = new symbol_sdk_1.RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();
const searchCriteria = {
group: symbol_sdk_1.TransactionGroup.Confirmed,
address,
pageNumber: 1,
pageSize: 100,
};
transactionHttp.search(searchCriteria).subscribe((page) => console.log(page.data), (err) => console.error(err));
final TransactionRepository transactionRepository = repositoryFactory
.createTransactionRepository();
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(
transactionRepository);
Observable<Transaction> transactions = streamer
.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED)
.address(signer.getAddress()));
System.out.println(transactions.toList().toFuture().get());
3. The API returns pages with up to 100 transactions. The page object contains meta information about the total amount of transactions and pages available.
より多くのトランザクションを取得するには、リクエストを繰り返し行う必要があります。追加の呼び出しごとに pageNumber
を 1 単位ずつ増やします。
const searchCriteria = {group: TransactionGroup.Confirmed, address, pageNumber: 2, pageSize: 100};
4. Since the transaction collection might grow while paginating, it's advised to set the first transaction you want to start pagination.
Set an offset
value with the first transaction internal identifier.
const searchCriteria = {group: TransactionGroup.Confirmed, address, pageNumber: 2, pageSize: 100, id:85BBEA6CC462B244};
ターミナルウィンドウを開き、次のコマンドを実行します。
TCHBDE-NCLKEB-ILBPWP-3JPB2X-NY64OE-7PYHHE-32I
をあなたがクエリを発行したいアドレスに置き換えます。
symbol-cli transaction search --address TCHBDE-NCLKEB-ILBPWP-3JPB2X-NY64OE-7PYHHE-32I