Java Code Examples for org.web3j.utils.Convert.Unit

The following examples show how to use org.web3j.utils.Convert.Unit. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ethsigner   Source File: ReadTimeoutAcceptanceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void submittingTransactionReturnsAGatewayTimeoutError() {
  final String recipient = "0x1b00ba00ca00bb00aa00bc00be00ac00ca00da00";
  final BigInteger transferAmountWei = Convert.toWei("15.5", Unit.ETHER).toBigIntegerExact();

  final Transaction transaction =
      Transaction.createEtherTransaction(
          richBenefactor().address(),
          richBenefactor().nextNonceAndIncrement(),
          GAS_PRICE,
          INTRINSIC_GAS,
          recipient,
          transferAmountWei);
  final SignerResponse<JsonRpcErrorResponse> signerResponse =
      ethSigner.transactions().submitExceptional(transaction);
  assertThat(signerResponse.status()).isEqualTo(GATEWAY_TIMEOUT);
  assertThat(signerResponse.jsonRpc().getError())
      .isEqualTo(CONNECTION_TO_DOWNSTREAM_NODE_TIMED_OUT);
}
 
Example 2
Source Project: ethsigner   Source File: ReadTimeoutAcceptanceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void submittingTransactionWithoutNonceReturnsAGatewayTimeoutError() {
  final String recipient = "0x1b00ba00ca00bb00aa00bc00be00ac00ca00da00";
  final BigInteger transferAmountWei = Convert.toWei("15.5", Unit.ETHER).toBigIntegerExact();

  final Transaction transaction =
      Transaction.createEtherTransaction(
          richBenefactor().address(),
          null,
          GAS_PRICE,
          INTRINSIC_GAS,
          recipient,
          transferAmountWei);
  final SignerResponse<JsonRpcErrorResponse> signerResponse =
      ethSigner.transactions().submitExceptional(transaction);
  assertThat(signerResponse.status()).isEqualTo(GATEWAY_TIMEOUT);
  assertThat(signerResponse.jsonRpc().getError())
      .isEqualTo(CONNECTION_TO_DOWNSTREAM_NODE_TIMED_OUT);
}
 
Example 3
Source Project: ethsigner   Source File: ConnectionTimeoutAcceptanceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void submittingTransactionReturnsAGatewayTimeoutError() {
  final String recipient = "0x1b00ba00ca00bb00aa00bc00be00ac00ca00da00";
  final BigInteger transferAmountWei = Convert.toWei("15.5", Unit.ETHER).toBigIntegerExact();

  final Transaction transaction =
      Transaction.createEtherTransaction(
          richBenefactor().address(),
          richBenefactor().nextNonceAndIncrement(),
          GAS_PRICE,
          INTRINSIC_GAS,
          recipient,
          transferAmountWei);
  final SignerResponse<JsonRpcErrorResponse> signerResponse =
      ethSigner.transactions().submitExceptional(transaction);
  assertThat(signerResponse.status()).isEqualTo(GATEWAY_TIMEOUT);
  assertThat(signerResponse.jsonRpc().getError())
      .isEqualTo(CONNECTION_TO_DOWNSTREAM_NODE_TIMED_OUT);
}
 
Example 4
Source Project: ethsigner   Source File: ConnectionTimeoutAcceptanceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void submittingTransactionWithoutNonceReturnsAGatewayTimeoutError() {
  final String recipient = "0x1b00ba00ca00bb00aa00bc00be00ac00ca00da00";
  final BigInteger transferAmountWei = Convert.toWei("15.5", Unit.ETHER).toBigIntegerExact();

  final Transaction transaction =
      Transaction.createEtherTransaction(
          richBenefactor().address(),
          null,
          GAS_PRICE,
          INTRINSIC_GAS,
          recipient,
          transferAmountWei);
  final SignerResponse<JsonRpcErrorResponse> signerResponse =
      ethSigner.transactions().submitExceptional(transaction);
  assertThat(signerResponse.status()).isEqualTo(GATEWAY_TIMEOUT);
  assertThat(signerResponse.jsonRpc().getError())
      .isEqualTo(CONNECTION_TO_DOWNSTREAM_NODE_TIMED_OUT);
}
 
Example 5
void performTransaction() {
  final BigInteger transferAmountWei = Convert.toWei("1.75", Unit.ETHER).toBigIntegerExact();

  final BigInteger startBalance = ethNode.accounts().balance(RECIPIENT);
  final Transaction transaction =
      Transaction.createEtherTransaction(
          richBenefactor().address(),
          null,
          GAS_PRICE,
          INTRINSIC_GAS,
          RECIPIENT,
          transferAmountWei);

  final String hash = ethSigner.transactions().submit(transaction);
  ethNode.transactions().awaitBlockContaining(hash);

  final BigInteger expectedEndBalance = startBalance.add(transferAmountWei);
  final BigInteger actualEndBalance = ethNode.accounts().balance(RECIPIENT);
  assertThat(actualEndBalance).isEqualTo(expectedEndBalance);
}
 
Example 6
@Test
public void valueTransfer() {
  final BigInteger transferAmountWei = Convert.toWei("1.75", Unit.ETHER).toBigIntegerExact();
  final BigInteger startBalance = ethNode().accounts().balance(RECIPIENT);
  final Transaction transaction =
      Transaction.createEtherTransaction(
          richBenefactor().address(),
          null,
          GAS_PRICE,
          INTRINSIC_GAS,
          RECIPIENT,
          transferAmountWei);

  final String hash = ethSigner().transactions().submit(transaction);
  ethNode().transactions().awaitBlockContaining(hash);

  final BigInteger expectedEndBalance = startBalance.add(transferAmountWei);
  final BigInteger actualEndBalance = ethNode().accounts().balance(RECIPIENT);
  assertThat(actualEndBalance).isEqualTo(expectedEndBalance);
}
 
Example 7
Source Project: ethsigner   Source File: ValueTransferAcceptanceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void valueTransfer() {
  final BigInteger transferAmountWei = Convert.toWei("1.75", Unit.ETHER).toBigIntegerExact();
  final BigInteger startBalance = ethNode().accounts().balance(RECIPIENT);
  final Transaction transaction =
      Transaction.createEtherTransaction(
          richBenefactor().address(),
          null,
          GAS_PRICE,
          INTRINSIC_GAS,
          RECIPIENT,
          transferAmountWei);

  final String hash = ethSigner().transactions().submit(transaction);
  ethNode().transactions().awaitBlockContaining(hash);

  final BigInteger expectedEndBalance = startBalance.add(transferAmountWei);
  final BigInteger actualEndBalance = ethNode().accounts().balance(RECIPIENT);
  assertThat(actualEndBalance).isEqualTo(expectedEndBalance);
}
 
Example 8
Source Project: ethsigner   Source File: ValueTransferAcceptanceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void multipleValueTransfers() {
  final BigInteger transferAmountWei = Convert.toWei("1", Unit.ETHER).toBigIntegerExact();
  final BigInteger startBalance = ethNode().accounts().balance(RECIPIENT);
  final Transaction transaction =
      Transaction.createEtherTransaction(
          richBenefactor().address(),
          null,
          GAS_PRICE,
          INTRINSIC_GAS,
          RECIPIENT,
          transferAmountWei);

  String hash = null;
  for (int i = 0; i < FIFTY_TRANSACTIONS; i++) {
    hash = ethSigner().transactions().submit(transaction);
  }
  ethNode().transactions().awaitBlockContaining(hash);

  final BigInteger endBalance = ethNode().accounts().balance(RECIPIENT);
  final BigInteger numberOfTransactions = BigInteger.valueOf(FIFTY_TRANSACTIONS);
  assertThat(endBalance)
      .isEqualTo(startBalance.add(transferAmountWei.multiply(numberOfTransactions)));
}
 
Example 9
Source Project: ethsigner   Source File: ValueTransferAcceptanceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void valueTransferNonceTooLow() {
  valueTransfer(); // call this test to increment the nonce
  final BigInteger transferAmountWei = Convert.toWei("15.5", Unit.ETHER).toBigIntegerExact();
  final Transaction transaction =
      Transaction.createEtherTransaction(
          richBenefactor().address(),
          BigInteger.ZERO,
          GAS_PRICE,
          INTRINSIC_GAS,
          RECIPIENT,
          transferAmountWei);

  final SignerResponse<JsonRpcErrorResponse> jsonRpcErrorResponseSignerResponse =
      ethSigner().transactions().submitExceptional(transaction);

  assertThat(jsonRpcErrorResponseSignerResponse.jsonRpc().getError())
      .isEqualTo(JsonRpcError.NONCE_TOO_LOW);
}
 
Example 10
Source Project: besu   Source File: Amount.java    License: Apache License 2.0 6 votes vote down vote up
public Amount subtract(final Amount subtracting) {

    final Unit denominator;
    if (unit.getWeiFactor().compareTo(subtracting.unit.getWeiFactor()) < 0) {
      denominator = unit;
    } else {
      denominator = subtracting.unit;
    }

    final BigDecimal result =
        Convert.fromWei(
            Convert.toWei(value, unit).subtract(Convert.toWei(subtracting.value, subtracting.unit)),
            denominator);

    return new Amount(result, denominator);
  }
 
Example 11
Source Project: client-sdk-java   Source File: SlashScenario.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 正常的场景:
 * 初始化账户余额
 * 举报双签(3000)
 * 查询节点是否已被举报过多签(3001)
 */
@Test
public void executeScenario() throws Exception {
	//初始化账户余额
	transfer();
	
	BigInteger slashBalance = web3j.platonGetBalance(slashCredentials.getAddress(), DefaultBlockParameterName.LATEST).send().getBalance();
	assertTrue(new BigDecimal(slashBalance).compareTo(Convert.fromVon(transferValue, Unit.VON))>=0);
	
	//举报双签(3000)
	BaseResponse reportDuplicateSignResponse = reportDuplicateSign();
	assertTrue(reportDuplicateSignResponse.toString(),reportDuplicateSignResponse.getCode()>=0);
	
	//查询节点是否已被举报过多签(3001)
	BaseResponse checkDuplicateSignResponse = checkDuplicateSign();
	assertTrue(checkDuplicateSignResponse.toString(),checkDuplicateSignResponse.isStatusOk());
	
}
 
Example 12
Source Project: client-sdk-java   Source File: RestrictingScenario.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *  正常的场景:
 *  初始化账户余额
 *  创建锁仓计划(4000)
 *  获取锁仓信息(4100)
 */
@Test
public void executeScenario() throws Exception {
	//初始化账户余额
	transfer();
	BigInteger restrictingBalance = web3j.platonGetBalance(restrictingSendCredentials.getAddress(), DefaultBlockParameterName.LATEST).send().getBalance();
	assertTrue(new BigDecimal(restrictingBalance).compareTo(Convert.fromVon(transferValue, Unit.VON))>=0);
	
	//创建锁仓计划(4000)
	TransactionResponse createRestrictingPlanResponse = createRestrictingPlan();
	assertTrue(createRestrictingPlanResponse.toString(),createRestrictingPlanResponse.isStatusOk());

	//获取锁仓信息(4100)
	CallResponse<RestrictingItem> getRestrictingPlanInfoResponse = getRestrictingPlanInfo();
	assertTrue(getRestrictingPlanInfoResponse.toString(),getRestrictingPlanInfoResponse.isStatusOk());
}
 
Example 13
Source Project: ethsigner   Source File: ClientSideTlsAcceptanceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
void ethSignerDoesNotConnectToServerNotSpecifiedInTrustStore(@TempDir Path workDir)
    throws Exception {
  final TlsCertificateDefinition serverPresentedCert =
      TlsCertificateDefinition.loadFromResource("tls/cert1.pfx", "password");
  final TlsCertificateDefinition ethSignerCert =
      TlsCertificateDefinition.loadFromResource("tls/cert2.pfx", "password2");
  final TlsCertificateDefinition ethSignerExpectedServerCert =
      TlsCertificateDefinition.loadFromResource("tls/cert2.pfx", "password2");

  final HttpServer web3ProviderHttpServer =
      serverFactory.create(serverPresentedCert, ethSignerCert, workDir);

  signer =
      createAndStartSigner(
          ethSignerCert,
          ethSignerExpectedServerCert,
          web3ProviderHttpServer.actualPort(),
          0,
          workDir);

  assertThatThrownBy(() -> signer.accounts().balance("0x123456"))
      .isInstanceOf(ClientConnectionException.class)
      .hasMessageContaining(String.valueOf(BAD_GATEWAY.code()));

  // ensure submitting a transaction results in the same behaviour
  final Transaction transaction =
      Transaction.createEtherTransaction(
          signer.accounts().richBenefactor().address(),
          null,
          GAS_PRICE,
          INTRINSIC_GAS,
          "0x1b00ba00ca00bb00aa00bc00be00ac00ca00da00",
          Convert.toWei("1.75", Unit.ETHER).toBigIntegerExact());

  assertThatThrownBy(() -> signer.transactions().submit(transaction))
      .isInstanceOf(ClientConnectionException.class)
      .hasMessageContaining(String.valueOf(BAD_GATEWAY.code()));
}
 
Example 14
Source Project: besu   Source File: ExpectAccountBalance.java    License: Apache License 2.0 5 votes vote down vote up
public ExpectAccountBalance(
    final EthTransactions eth,
    final Account account,
    final BigDecimal expectedBalance,
    final Unit balanceUnit) {
  this.account = account;
  this.eth = eth;
  this.expectedBalance = toWei(expectedBalance, balanceUnit).toBigIntegerExact();
}
 
Example 15
Source Project: besu   Source File: ExpectAccountBalanceAtBlock.java    License: Apache License 2.0 5 votes vote down vote up
public ExpectAccountBalanceAtBlock(
    final EthTransactions eth,
    final Account account,
    final BigInteger block,
    final BigDecimal expectedBalance,
    final Unit balanceUnit) {
  this.account = account;
  this.eth = eth;
  this.block = block;
  this.expectedBalance = toWei(expectedBalance, balanceUnit).toBigIntegerExact();
}
 
Example 16
Source Project: besu   Source File: ExpectAccountBalanceNotChanging.java    License: Apache License 2.0 5 votes vote down vote up
public ExpectAccountBalanceNotChanging(
    final EthTransactions eth,
    final Account account,
    final BigDecimal startBalance,
    final Unit balanceUnit) {
  this.account = account;
  this.eth = eth;
  this.startBalance = toWei(startBalance, balanceUnit).toBigIntegerExact();
}
 
Example 17
Source Project: client-sdk-java   Source File: StakingScenario.java    License: Apache License 2.0 5 votes vote down vote up
public TransactionResponse delegate() throws Exception {
    StakingAmountType stakingAmountType = StakingAmountType.FREE_AMOUNT_TYPE;
    BigDecimal stakingAmount = Convert.toVon("500000", Unit.LAT);

    PlatonSendTransaction platonSendTransaction = delegateContract.delegateReturnTransaction(nodeId, stakingAmountType, stakingAmount.toBigInteger()).send();
    TransactionResponse baseResponse = delegateContract.getTransactionResponse(platonSendTransaction).send();
    return baseResponse;
}
 
Example 18
Source Project: client-sdk-java   Source File: StakingScenario.java    License: Apache License 2.0 5 votes vote down vote up
public TransactionResponse addStaking() throws Exception {
    StakingAmountType stakingAmountType = StakingAmountType.FREE_AMOUNT_TYPE;
    BigDecimal addStakingAmount = Convert.toVon("4000000", Unit.LAT).add(new BigDecimal("999999999999999998"));

    PlatonSendTransaction platonSendTransaction = stakingContract.addStakingReturnTransaction(nodeId, stakingAmountType, addStakingAmount.toBigInteger()).send();
    TransactionResponse baseResponse = stakingContract.getTransactionResponse(platonSendTransaction).send();
    return baseResponse;
}
 
Example 19
Source Project: client-sdk-java   Source File: StakingScenario.java    License: Apache License 2.0 5 votes vote down vote up
public TransactionResponse staking() throws Exception {
    StakingAmountType stakingAmountType = StakingAmountType.FREE_AMOUNT_TYPE;
    String benifitAddress = benefitCredentials.getAddress();
    String externalId = "";
    String nodeName = "integration-node1";
    String webSite = "https://www.platon.network/#/";
    String details = "integration-node1-details";
    BigDecimal stakingAmount = Convert.toVon("5000000", Unit.LAT).add(BigDecimal.valueOf(1L));
    BigInteger rewardPer = BigInteger.valueOf(1000L);

    PlatonSendTransaction platonSendTransaction = stakingContract.stakingReturnTransaction(new StakingParam.Builder()
            .setNodeId(nodeId)
            .setAmount(stakingAmount.toBigInteger())
            .setStakingAmountType(stakingAmountType)
            .setBenifitAddress(benifitAddress)
            .setExternalId(externalId)
            .setNodeName(nodeName)
            .setWebSite(webSite)
            .setDetails(details)
            .setBlsPubKey(blsPubKey)
            .setProcessVersion(web3j.getProgramVersion().send().getAdminProgramVersion())
            .setBlsProof(web3j.getSchnorrNIZKProve().send().getAdminSchnorrNIZKProve())
            .setRewardPer(rewardPer)
            .build()).send();
    TransactionResponse baseResponse = stakingContract.getTransactionResponse(platonSendTransaction).send();
    return baseResponse;
}
 
Example 20
Source Project: client-sdk-java   Source File: StakingContractTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void staking() throws Exception {   	
    try {
    	StakingAmountType stakingAmountType = StakingAmountType.FREE_AMOUNT_TYPE;
    	String benifitAddress = benefitCredentials.getAddress();
    	String externalId = "";
        String nodeName = "chendai-node3";
        String webSite = "www.baidu.com";
        String details = "chendai-node3-details";
        BigDecimal stakingAmount = Convert.toVon("5000000", Unit.LAT);
        BigInteger rewardPer = BigInteger.valueOf(1000L);
    	
        PlatonSendTransaction platonSendTransaction = stakingContract.stakingReturnTransaction(new StakingParam.Builder()
                .setNodeId(nodeId)
                .setAmount(stakingAmount.toBigInteger())  
                .setStakingAmountType(stakingAmountType)
                .setBenifitAddress(benifitAddress)
                .setExternalId(externalId)
                .setNodeName(nodeName)
                .setWebSite(webSite)
                .setDetails(details)
                .setBlsPubKey(blsPubKey)
                .setProcessVersion(web3j.getProgramVersion().send().getAdminProgramVersion())
                .setBlsProof(web3j.getSchnorrNIZKProve().send().getAdminSchnorrNIZKProve())
                .setRewardPer(rewardPer)
                .build()).send();
        TransactionResponse baseResponse = stakingContract.getTransactionResponse(platonSendTransaction).send();
        System.out.println(baseResponse.toString());  //394
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 21
Source Project: client-sdk-java   Source File: StakingContractTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void addStaking() {
    try {
    	StakingAmountType stakingAmountType = StakingAmountType.FREE_AMOUNT_TYPE;
        BigDecimal addStakingAmount = Convert.toVon("4000000", Unit.LAT).add(new BigDecimal("999999999999999998"));
    	
        PlatonSendTransaction platonSendTransaction = stakingContract.addStakingReturnTransaction(nodeId, stakingAmountType, addStakingAmount.toBigInteger()).send();
        TransactionResponse baseResponse = stakingContract.getTransactionResponse(platonSendTransaction).send();
        System.out.println(baseResponse.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 22
Source Project: besu   Source File: Account.java    License: Apache License 2.0 4 votes vote down vote up
public Condition balanceEquals(final int expectedBalance) {
  return new ExpectAccountBalance(eth, this, BigDecimal.valueOf(expectedBalance), Unit.ETHER);
}
 
Example 23
Source Project: besu   Source File: Account.java    License: Apache License 2.0 4 votes vote down vote up
public Condition balanceDoesNotChange(final int startingBalance) {
  return new ExpectAccountBalanceNotChanging(
      eth, this, BigDecimal.valueOf(startingBalance), Unit.ETHER);
}
 
Example 24
Source Project: besu   Source File: Amount.java    License: Apache License 2.0 4 votes vote down vote up
private Amount(final BigDecimal value, final Unit unit) {
  this.value = value;
  this.unit = unit;
}
 
Example 25
Source Project: besu   Source File: Amount.java    License: Apache License 2.0 4 votes vote down vote up
public Unit getUnit() {
  return unit;
}
 
Example 26
Source Project: client-sdk-java   Source File: SlashScenario.java    License: Apache License 2.0 4 votes vote down vote up
public void transfer() throws Exception {
	Transfer.sendFunds(web3j, superCredentials, chainId, slashCredentials.getAddress(), transferValue, Unit.LAT).send();
}
 
Example 27
Source Project: client-sdk-java   Source File: RestrictingScenario.java    License: Apache License 2.0 4 votes vote down vote up
public void transfer() throws Exception {
	Transfer.sendFunds(web3j, superCredentials, chainId, restrictingSendCredentials.getAddress(), transferValue, Unit.LAT).send();
}
 
Example 28
Source Project: client-sdk-java   Source File: StakingScenario.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 正常的场景:
 * 初始化账户余额
 * 创建质押信息(1000)
 * 修改质押信息(1001)
 * 修改质押金额(1002)
 * 对质押委托(1004)
 * 查询当前结算周期的验证人队列(1100)
 * 查询当前共识周期的验证人列表(1101)
 * 查询所有实时的候选人列表(1102)
 * 查询当前账户地址所委托的节点的NodeID和质押Id(1103)
 * 查询当前单个委托信息(1104)
 * 查询当前节点的质押信息(1105)
 * 对质押解除委托(1005)
 * 退出质押(1003)
 */
@Test
public void executeScenario() throws Exception {
    //初始化账户余额
    transfer();
    BigInteger stakingBalance = web3j.platonGetBalance(stakingCredentials.getAddress(), DefaultBlockParameterName.LATEST).send().getBalance();
    BigInteger delegateBalance = web3j.platonGetBalance(delegateCredentials.getAddress(), DefaultBlockParameterName.LATEST).send().getBalance();

    assertTrue(new BigDecimal(stakingBalance).compareTo(Convert.fromVon(transferValue, Unit.VON)) >= 0);
    assertTrue(new BigDecimal(delegateBalance).compareTo(Convert.fromVon(transferValue, Unit.VON)) >= 0);

    //创建质押信息(1000)
    TransactionResponse createStakingResponse = staking();
    assertTrue(createStakingResponse.toString(), createStakingResponse.isStatusOk());

    //修改质押信息(1001)
    TransactionResponse updateStakingResponse = updateStakingInfo();
    assertTrue(updateStakingResponse.toString(), updateStakingResponse.isStatusOk());

    //修改质押金额(1002)
    TransactionResponse addStakingResponse = addStaking();
    assertTrue(addStakingResponse.toString(), addStakingResponse.isStatusOk());

    //对质押委托(1004)
    TransactionResponse delegateResponse = delegate();
    assertTrue(delegateResponse.toString(), delegateResponse.isStatusOk());

    //查询当前账户地址所委托的节点的NodeID和质押Id(1103)
    CallResponse<List<DelegationIdInfo>> getRelatedListByDelAddrResponse = getRelatedListByDelAddr();
    assertTrue(getRelatedListByDelAddrResponse.toString(), getRelatedListByDelAddrResponse.isStatusOk());

    List<DelegationIdInfo> delegationIdInfos = getRelatedListByDelAddrResponse.getData();
    assertTrue(delegationIdInfos != null && !delegationIdInfos.isEmpty());

    //查询当前单个委托信息(1104)
    CallResponse<Delegation> getDelegateResponse = getDelegateInfo(delegationIdInfos.get(0).getStakingBlockNum());
    assertTrue(getDelegateResponse.toString(), getDelegateResponse.isStatusOk());

    //查询当前节点的质押信息(1105)
    CallResponse<Node> getStakingInfoResponse = getStakingInfo();
    assertTrue(getStakingInfoResponse.toString(), getStakingInfoResponse.isStatusOk());

    //对质押解除委托(1005)
    TransactionResponse unDelegateResponse = unDelegate(delegationIdInfos.get(0).getStakingBlockNum());
    assertTrue(unDelegateResponse.toString(), unDelegateResponse.isStatusOk());

    //退出质押(1003)
    TransactionResponse unStakingResponse = unStaking();
    assertTrue(unStakingResponse.toString(), unStakingResponse.isStatusOk());
}
 
Example 29
Source Project: client-sdk-java   Source File: StakingScenario.java    License: Apache License 2.0 4 votes vote down vote up
public TransactionResponse unDelegate(BigInteger stakingBlockNum) throws Exception {
    BigDecimal stakingAmount = Convert.toVon("500000", Unit.LAT);
    PlatonSendTransaction platonSendTransaction = delegateContract.unDelegateReturnTransaction(nodeId, stakingBlockNum, stakingAmount.toBigInteger()).send();
    TransactionResponse baseResponse = delegateContract.getTransactionResponse(platonSendTransaction).send();
    return baseResponse;
}
 
Example 30
Source Project: client-sdk-java   Source File: StakingScenario.java    License: Apache License 2.0 4 votes vote down vote up
public void transfer() throws Exception {
    Transfer.sendFunds(web3j, superCredentials, chainId, stakingCredentials.getAddress(), transferValue, Unit.LAT).send();
    Transfer.sendFunds(web3j, superCredentials, chainId, delegateCredentials.getAddress(), transferValue, Unit.LAT).send();
}