AccountOperation¶
계정과 관련되어 있는 연산들을 제공합니다.
Get Account State¶
계정의 상태 조회.
AccountAddress accountAddress = AccountAddress
.of("AmNrsAqkXhQfE6sGxTutQkf9ekaYowaJFLekEm8qvDr1RB1AnsiM");
AccountState accountState = client.getAccountOperation().getState(accountAddress);
System.out.println("AccountState: " + accountState);
Create Name¶
Transaction을 서명한 계정의 소유가 되는 이름을 생성.
// prepare a signer
AergoKey signer = richKey;
// make a naming transaction
Name name = randomName();
long nonce = nonceProvider.incrementAndGetNonce(signer.getAddress());
TxHash txHash = client.getAccountOperation().createNameTx(signer, name, nonce);
System.out.println("Create name tx hash: " + txHash);
Update Name¶
이미 생성되어 있는 이름의 소유권을 다른 계정으로 넘김. 이 연산은 원래 소유자만 할 수 있습니다.
// prepare a signer
AergoKey signer = richKey;
// create an name
Name name = randomName();
long nonce1 = nonceProvider.incrementAndGetNonce(signer.getAddress());
client.getAccountOperation().createNameTx(signer, name, nonce1);
// sleep
Thread.sleep(2000L);
// update an name
AccountAddress nextOwner = AccountAddress
.of("AmNrsAqkXhQfE6sGxTutQkf9ekaYowaJFLekEm8qvDr1RB1AnsiM");
long nonce2 = nonceProvider.incrementAndGetNonce(signer.getAddress());
TxHash txHash = client.getAccountOperation().updateNameTx(signer, name, nextOwner, nonce2);
System.out.println("Update name tx hash: " + txHash);
Get Name Owner¶
이름의 소유 계정을 조회합니다.
현재 블록 기준으로 조회합니다.
// get name owner at current block
Name name = Name.of("samplename11");
AccountAddress nameOwner = client.getAccountOperation().getNameOwner(name);
System.out.println("Nonce owner: " + nameOwner);
특정 블록 기준으로 조회합니다.
// get name owner at block 3
Name name = Name.of("samplename11");
AccountAddress nameOwner = client.getAccountOperation().getNameOwner(name, 3);
System.out.println("Nonce owner: " + nameOwner);
Stake¶
Aergo를 staking합니다.
// prepare a signer
AergoKey signer = richKey;
// stake 10000 aergo
Aer amount = Aer.of("10000", Unit.AERGO);
long nonce = nonceProvider.incrementAndGetNonce(signer.getAddress());
TxHash txHash = client.getAccountOperation().stakeTx(signer, amount, nonce);
System.out.println("Stake tx hash: " + txHash);
Unstake¶
Staking되어 있는 Aergo를 UnStaking합니다.
// prepare a signer
AergoKey signer = richKey;
// unstake 10000 aergo
Aer amount = Aer.of("10000", Unit.AERGO);
long nonce = nonceProvider.incrementAndGetNonce(signer.getAddress());
TxHash txHash = client.getAccountOperation().unstakeTx(signer, amount, nonce);
System.out.println("Unstake tx hash: " + txHash);
Get Stake Info¶
계정의 staking 정보를 조회합니다.
AccountAddress accountAddress = AccountAddress
.of("AmNrsAqkXhQfE6sGxTutQkf9ekaYowaJFLekEm8qvDr1RB1AnsiM");
StakeInfo stakeInfo = client.getAccountOperation().getStakingInfo(accountAddress);
System.out.println("Stake info: " + stakeInfo);
Vote¶
Vote id에 해당되는 candidate에 투표합니다.
// prepare a signer
AergoKey signer = richKey;
// vote to "voteBP"
List<String> candidates = asList("16Uiu2HAkwWbv8nKx7S6S5NMvUpTLNeXMVCPr3NTnrx6rBPYYiQ4K");
long nonce = nonceProvider.incrementAndGetNonce(signer.getAddress());
TxHash txHash = client.getAccountOperation().voteTx(signer, "voteBp", candidates, nonce);
System.out.println("Vote tx hash: " + txHash);
Get Vote of Account¶
계정의 투표 정보를 조회합니다.
AccountAddress accountAddress = AccountAddress
.of("AmNrsAqkXhQfE6sGxTutQkf9ekaYowaJFLekEm8qvDr1RB1AnsiM");
AccountTotalVote voteInfo = client.getAccountOperation().getVotesOf(accountAddress);
System.out.println("Vote info: " + voteInfo);
Get Vote Result¶
Vote id에 해당되는 투표 결과를 조회합니다.
// get vote result for vote id "voteBP" for top 23 candidates.
List<ElectedCandidate> elected = client.getAccountOperation().listElected("voteBP", 23);
System.out.println("Elected: " + elected);