org.web3j.protocol.core.methods.response.TransactionReceipt Java Examples

The following examples show how to use org.web3j.protocol.core.methods.response.TransactionReceipt. 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 File: ContractTest.java    From web3j with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeployInvalidContractAddress() throws Throwable {
    TransactionReceipt transactionReceipt = new TransactionReceipt();
    transactionReceipt.setTransactionHash(TRANSACTION_HASH);

    prepareTransaction(transactionReceipt);
    ContractGasProvider contractGasProvider = new DefaultGasProvider();
    String encodedConstructor =
            FunctionEncoder.encodeConstructor(
                    Collections.<Type>singletonList(new Uint256(BigInteger.TEN)));
    assertThrows(
            RuntimeException.class,
            () ->
                    TestContract.deployRemoteCall(
                                    TestContract.class,
                                    web3j,
                                    SampleKeys.CREDENTIALS,
                                    contractGasProvider,
                                    "0xcafed00d",
                                    encodedConstructor,
                                    BigInteger.ZERO)
                            .send());
}
 
Example #2
Source File: DelegateContract.java    From client-sdk-java with Apache License 2.0 6 votes vote down vote up
/**
 *  获得解除委托时所提取的委托收益(当减持/撤销委托成功时调用)
 *
 * @param transactionReceipt
 * @return
 * @throws TransactionException
 */
public BigInteger decodeUnDelegateLog(TransactionReceipt transactionReceipt) throws TransactionException {
    List<Log> logs = transactionReceipt.getLogs();
    if(logs==null||logs.isEmpty()){
        throw new TransactionException("TransactionReceipt logs is empty");
    }

    String logData = logs.get(0).getData();
    if(null == logData || "".equals(logData) ){
        throw new TransactionException("TransactionReceipt logs[0].data is empty");
    }

    RlpList rlp = RlpDecoder.decode(Numeric.hexStringToByteArray(logData));
    List<RlpType> rlpList = ((RlpList)(rlp.getValues().get(0))).getValues();
    String decodedStatus = new String(((RlpString)rlpList.get(0)).getBytes());
    int statusCode = Integer.parseInt(decodedStatus);

    if(statusCode != ErrorCode.SUCCESS){
        throw new TransactionException("TransactionResponse code is 0");
    }

    return  ((RlpString)((RlpList)RlpDecoder.decode(((RlpString)rlpList.get(1)).getBytes())).getValues().get(0)).asPositiveBigInteger();
}
 
Example #3
Source File: ContractTest.java    From client-sdk-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testStaticGasProvider() throws IOException, TransactionException {
    ContractGasProvider gasProvider = new ContractGasProvider(BigInteger.TEN, BigInteger.ONE);
    TransactionManager txManager = mock(TransactionManager.class);
    when(txManager.executeTransaction(any(), any(), any(), any(), any()))
            .thenReturn(new TransactionReceipt());

    contract = new TestContract(ADDRESS, web3j, txManager, gasProvider);

    Function func = new Function("test",
            Arrays.<Type>asList(), Collections.<TypeReference<?>>emptyList());
    contract.executeTransaction(func);

    verify(txManager).executeTransaction(eq(BigInteger.TEN),
            eq(BigInteger.ONE), any(), any(), any());
}
 
Example #4
Source File: BaseContract.java    From client-sdk-java with Apache License 2.0 6 votes vote down vote up
private TransactionResponse getResponseFromTransactionReceipt(TransactionReceipt transactionReceipt) throws TransactionException {
	List<Log> logs = transactionReceipt.getLogs();
       if(logs==null||logs.isEmpty()){
       	 throw new TransactionException("TransactionReceipt logs is empty");
       }

	String logData = logs.get(0).getData();
	if(null == logData || "".equals(logData) ){
		throw new TransactionException("TransactionReceipt log data is empty");
	}

       RlpList rlp = RlpDecoder.decode(Numeric.hexStringToByteArray(logData));
       List<RlpType> rlpList = ((RlpList)(rlp.getValues().get(0))).getValues();
       String decodedStatus = new String(((RlpString)rlpList.get(0)).getBytes());
       int statusCode = Integer.parseInt(decodedStatus);
       
       TransactionResponse transactionResponse = new TransactionResponse();
       transactionResponse.setCode(statusCode);
       transactionResponse.setTransactionReceipt(transactionReceipt);
       
       return transactionResponse;
}
 
Example #5
Source File: WalletSendFunds.java    From etherscan-explorer with GNU General Public License v3.0 6 votes vote down vote up
private TransactionReceipt performTransfer(
        Web3j web3j, String destinationAddress, Credentials credentials,
        BigDecimal amountInWei) {

    console.printf("Commencing transfer (this may take a few minutes) ");
    try {
        Future<TransactionReceipt> future = Transfer.sendFunds(
                web3j, credentials, destinationAddress, amountInWei, Convert.Unit.WEI)
                .sendAsync();

        while (!future.isDone()) {
            console.printf(".");
            Thread.sleep(500);
        }
        console.printf("$%n%n");
        return future.get();
    } catch (InterruptedException | ExecutionException | TransactionException | IOException e) {
        exitError("Problem encountered transferring funds: \n" + e.getMessage());
    }
    throw new RuntimeException("Application exit failure");
}
 
Example #6
Source File: FunctionWrappersIT.java    From etherscan-explorer with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testFibonacciNotify() throws Exception {
    Fibonacci fibonacci = Fibonacci.load(
            "0x3c05b2564139fb55820b18b72e94b2178eaace7d", Web3j.build(new HttpService()),
            ALICE, GAS_PRICE, GAS_LIMIT);

    TransactionReceipt transactionReceipt = fibonacci.fibonacciNotify(
            BigInteger.valueOf(15)).send();

    Fibonacci.NotifyEventResponse result = fibonacci.getNotifyEvents(transactionReceipt).get(0);

    assertThat(result.input,
            equalTo(new Uint256(BigInteger.valueOf(15))));

    assertThat(result.result,
            equalTo(new Uint256(BigInteger.valueOf(610))));
}
 
Example #7
Source File: Scenario.java    From web3j with Apache License 2.0 6 votes vote down vote up
private Optional<TransactionReceipt> getTransactionReceipt(
        String transactionHash, int sleepDuration, int attempts) throws Exception {

    Optional<TransactionReceipt> receiptOptional =
            sendTransactionReceiptRequest(transactionHash);
    for (int i = 0; i < attempts; i++) {
        if (!receiptOptional.isPresent()) {
            Thread.sleep(sleepDuration);
            receiptOptional = sendTransactionReceiptRequest(transactionHash);
        } else {
            break;
        }
    }

    return receiptOptional;
}
 
Example #8
Source File: JavaParser.java    From web3j with Apache License 2.0 6 votes vote down vote up
public String generateAssertionJavaPoetStringTypes() {
    Type returnType = getMethodReturnType();
    Object[] body = generatePlaceholderValues();
    StringBuilder symbolBuilder = new StringBuilder();
    symbolBuilder.append("$T.");
    if (returnType.equals(TransactionReceipt.class)) {
        symbolBuilder.append("assertTrue($L.isStatusOK())");
    } else {
        symbolBuilder.append("assertEquals(");
        if (returnType.getTypeName().contains("Tuple")) {
            symbolBuilder.append("new $T(");
            for (Type t : getTypeArray(returnType)) {
                symbolBuilder.append(mappingHelper.getPoetFormat().get(t)).append(", ");
            }
            symbolBuilder.deleteCharAt(symbolBuilder.lastIndexOf(", "));
            symbolBuilder.append(")");
        } else {
            symbolBuilder.append(mappingHelper.getPoetFormat().get(body[0]));
        }
        symbolBuilder.append(", ");
        symbolBuilder.append("$L");
        symbolBuilder.append(")");
    }

    return symbolBuilder.toString();
}
 
Example #9
Source File: KotlinParser.java    From web3j with Apache License 2.0 6 votes vote down vote up
public String generateAssertionKotlinPoetStringTypes() {
    Type returnType = getMethodReturnType();
    Object[] body = generatePlaceholderValues();
    StringBuilder symbolBuilder = new StringBuilder();
    symbolBuilder.append("%T.");
    if (returnType == TransactionReceipt.class) {
        symbolBuilder.append("assertTrue(%L.isStatusOK())");
    } else {
        symbolBuilder.append("assertEquals(");
        if (returnType.getTypeName().contains("Tuple")) {
            symbolBuilder.append(" %T(");
            for (Type t : getTypeArray(returnType)) {
                symbolBuilder.append(mappingHelper.getPoetFormat().get(t)).append(", ");
            }
            symbolBuilder.deleteCharAt(symbolBuilder.lastIndexOf(", "));
            symbolBuilder.append(")");
        } else {
            symbolBuilder.append(mappingHelper.getPoetFormat().get(body[0]));
        }
        symbolBuilder.append(", ");
        symbolBuilder.append("%L");
        symbolBuilder.append(")");
    }
    return symbolBuilder.toString();
}
 
Example #10
Source File: FunctionWrappersIT.java    From web3j with Apache License 2.0 6 votes vote down vote up
@Test
public void testFibonacciNotify() throws Exception {
    Fibonacci fibonacci =
            Fibonacci.load(
                    "0x3c05b2564139fb55820b18b72e94b2178eaace7d",
                    Web3j.build(new HttpService()),
                    ALICE,
                    STATIC_GAS_PROVIDER);

    TransactionReceipt transactionReceipt =
            fibonacci.fibonacciNotify(BigInteger.valueOf(15)).send();

    Fibonacci.NotifyEventResponse result = fibonacci.getNotifyEvents(transactionReceipt).get(0);

    assertEquals(result.input, (new Uint256(BigInteger.valueOf(15))));

    assertEquals(result.result, (new Uint256(BigInteger.valueOf(610))));
}
 
Example #11
Source File: RevertReasonExtractor.java    From web3j with Apache License 2.0 6 votes vote down vote up
/**
 * Extracts the error reason of a reverted transaction (if one exists and enabled).
 *
 * @param transactionReceipt the reverted transaction receipt
 * @param data the reverted transaction data
 * @param web3j Web3j instance
 * @param revertReasonCallEnabled flag of reason retrieval via additional call
 * @return the reverted transaction error reason if exists or null otherwise
 * @throws IOException if the call to the node fails
 */
public static String extractRevertReason(
        TransactionReceipt transactionReceipt,
        String data,
        Web3j web3j,
        Boolean revertReasonCallEnabled)
        throws IOException {

    if (transactionReceipt.getRevertReason() != null) {
        return transactionReceipt.getRevertReason();
    } else if (revertReasonCallEnabled) {
        String revertReason = retrieveRevertReason(transactionReceipt, data, web3j);
        if (revertReason != null) {
            transactionReceipt.setRevertReason(revertReason);
            return revertReason;
        }
    }
    return MISSING_REASON;
}
 
Example #12
Source File: Web3jUtils.java    From web3j_demo with Apache License 2.0 6 votes vote down vote up
/**
 * Waits for the receipt for the transaction specified by the provided tx hash.
 * Makes 40 attempts (waiting 1 sec. inbetween attempts) to get the receipt object.
 * In the happy case the tx receipt object is returned.
 * Otherwise, a runtime exception is thrown. 
 */
public static TransactionReceipt waitForReceipt(Web3j web3j, String transactionHash) 
		throws Exception 
{

	int attempts = Web3jConstants.CONFIRMATION_ATTEMPTS;
	int sleep_millis = Web3jConstants.SLEEP_DURATION;
	
	Optional<TransactionReceipt> receipt = getReceipt(web3j, transactionHash);

	while(attempts-- > 0 && !receipt.isPresent()) {
		Thread.sleep(sleep_millis);
		receipt = getReceipt(web3j, transactionHash);
	}

	if (attempts <= 0) {
		throw new RuntimeException("No Tx receipt received");
	}

	return receipt.get();
}
 
Example #13
Source File: ContractTest.java    From web3j with Apache License 2.0 6 votes vote down vote up
@Test
public void testTransactionFailedWithRevertReason() throws Exception {
    TransactionReceipt transactionReceipt = createFailedTransactionReceipt();
    prepareCall(OWNER_REVERT_MSG_HASH);

    TransactionException thrown =
            assertThrows(
                    TransactionException.class,
                    () -> {
                        prepareTransaction(transactionReceipt);

                        contract.performTransaction(
                                        new Address(BigInteger.TEN),
                                        new Uint256(BigInteger.ONE))
                                .send();
                    });

    assertEquals(
            String.format(
                    "Transaction %s has failed with status: %s. Gas used: 1. Revert reason: '%s'.",
                    TRANSACTION_HASH, TXN_FAIL_STATUS, OWNER_REVERT_MSG_STR),
            thrown.getMessage());
    assertEquals(transactionReceipt, thrown.getTransactionReceipt().get());
}
 
Example #14
Source File: ManagedTransaction.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
protected TransactionReceipt send(
        String to, String data, BigInteger value, BigInteger gasPrice, BigInteger gasLimit)
        throws IOException, TransactionException {

    return transactionManager.executeTransaction(
            gasPrice, gasLimit, to, data, value);
}
 
Example #15
Source File: Greeter.java    From web3j with Apache License 2.0 5 votes vote down vote up
public List<ModifiedEventResponse> getModifiedEvents(TransactionReceipt transactionReceipt) {
    List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(MODIFIED_EVENT, transactionReceipt);
    ArrayList<ModifiedEventResponse> responses = new ArrayList<ModifiedEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        ModifiedEventResponse typedResponse = new ModifiedEventResponse();
        typedResponse.log = eventValues.getLog();
        typedResponse.oldGreetingIdx = (byte[]) eventValues.getIndexedValues().get(0).getValue();
        typedResponse.newGreetingIdx = (byte[]) eventValues.getIndexedValues().get(1).getValue();
        typedResponse.oldGreeting = (String) eventValues.getNonIndexedValues().get(0).getValue();
        typedResponse.newGreeting = (String) eventValues.getNonIndexedValues().get(1).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #16
Source File: PublicResolver.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> setContent(byte[] node, byte[] hash) {
    Function function = new Function(
            "setContent",
            Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(node),
            new org.web3j.abi.datatypes.generated.Bytes32(hash)),
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #17
Source File: ERC20.java    From web3j with Apache License 2.0 5 votes vote down vote up
public List<ApprovalEventResponse> getApprovalEvents(TransactionReceipt transactionReceipt) {
    List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(APPROVAL_EVENT, transactionReceipt);
    ArrayList<ApprovalEventResponse> responses = new ArrayList<ApprovalEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        ApprovalEventResponse typedResponse = new ApprovalEventResponse();
        typedResponse.log = eventValues.getLog();
        typedResponse._owner = (String) eventValues.getIndexedValues().get(0).getValue();
        typedResponse._spender = (String) eventValues.getIndexedValues().get(1).getValue();
        typedResponse._value = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #18
Source File: PublicResolver.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
public List<AddrChangedEventResponse> getAddrChangedEvents(TransactionReceipt transactionReceipt) {
    final Event event = new Event("AddrChanged", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>() {}),
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
    List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
    ArrayList<AddrChangedEventResponse> responses = new ArrayList<AddrChangedEventResponse>(valueList.size());
    for (EventValues eventValues : valueList) {
        AddrChangedEventResponse typedResponse = new AddrChangedEventResponse();
        typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
        typedResponse.a = (String) eventValues.getNonIndexedValues().get(0).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #19
Source File: TransactionManager.java    From web3j with Apache License 2.0 5 votes vote down vote up
private TransactionReceipt processResponse(EthSendTransaction transactionResponse)
        throws IOException, TransactionException {
    if (transactionResponse.hasError()) {
        throw new RuntimeException(
                "Error processing transaction request: "
                        + transactionResponse.getError().getMessage());
    }

    String transactionHash = transactionResponse.getTransactionHash();

    return transactionReceiptProcessor.waitForTransactionReceipt(transactionHash);
}
 
Example #20
Source File: HumanStandardToken.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> approve(String _spender, BigInteger _value) {
    final Function function = new Function(
            "approve", 
            Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(_spender), 
            new org.web3j.abi.datatypes.generated.Uint256(_value)), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #21
Source File: RewardContract.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 *  获得提取的明细(当提取账户当前所有的可提取的委托奖励成功时调用)
 *
 * @param transactionReceipt
 * @return
 * @throws TransactionException
 */
public List<Reward> decodeWithdrawDelegateRewardLog(TransactionReceipt transactionReceipt) throws TransactionException {
    List<Log> logs = transactionReceipt.getLogs();
    if(logs==null||logs.isEmpty()){
        throw new TransactionException("TransactionReceipt logs is empty");
    }

    String logData = logs.get(0).getData();
    if(null == logData || "".equals(logData) ){
        throw new TransactionException("TransactionReceipt logs[0].data is empty");
    }

    RlpList rlp = RlpDecoder.decode(Numeric.hexStringToByteArray(logData));
    List<RlpType> rlpList = ((RlpList)(rlp.getValues().get(0))).getValues();
    String decodedStatus = new String(((RlpString)rlpList.get(0)).getBytes());
    int statusCode = Integer.parseInt(decodedStatus);

    if(statusCode != ErrorCode.SUCCESS){
        throw new TransactionException("TransactionResponse code is 0");
    }

    List<Reward> rewards = new ArrayList<>();
    ((RlpList)((RlpList)RlpDecoder.decode(((RlpString)rlpList.get(1)).getBytes())).getValues().get(0)).getValues()
            .stream()
            .forEach(rl -> {
                RlpList rlpL = (RlpList)rl;
                Reward reward = new Reward();
                reward.setNodeId(((RlpString)rlpL.getValues().get(0)).asString());
                reward.setStakingNum(((RlpString)rlpL.getValues().get(1)).asPositiveBigInteger());
                reward.setRewardBigIntegerValue((((RlpString)rlpL.getValues().get(2)).asPositiveBigInteger()));
                rewards.add(reward);
            });

    return  rewards;
}
 
Example #22
Source File: BlindAuction.java    From web3j with Apache License 2.0 5 votes vote down vote up
public RemoteCall<TransactionReceipt> withdraw() {
    final Function function = new Function(
            FUNC_WITHDRAW, 
            Arrays.<Type>asList(),
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #23
Source File: ContractTest.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testExtractEventParametersWithLogGivenATransactionReceipt() {

    final java.util.function.Function<String, Event> eventFactory = name ->
            new Event(name, emptyList(), emptyList());

    final BiFunction<Integer, Event, Log> logFactory = (logIndex, event) ->
            new Log(false, "" + logIndex, "0", "0x0", "0x0", "0", "0x" + logIndex, "", "",
                    singletonList(EventEncoder.encode(event)));

    final Event testEvent1 = eventFactory.apply("TestEvent1");
    final Event testEvent2 = eventFactory.apply("TestEvent2");

    final List<Log> logs = Arrays.asList(
            logFactory.apply(0, testEvent1),
            logFactory.apply(1, testEvent2)
    );

    final TransactionReceipt transactionReceipt = new TransactionReceipt();
    transactionReceipt.setLogs(logs);

    final List<Contract.EventValuesWithLog> eventValuesWithLogs1 =
            contract.extractEventParametersWithLog(testEvent1, transactionReceipt);

    assertEquals(eventValuesWithLogs1.size(), 1);
    assertEquals(eventValuesWithLogs1.get(0).getLog(), logs.get(0));

    final List<Contract.EventValuesWithLog> eventValuesWithLogs2 =
            contract.extractEventParametersWithLog(testEvent2, transactionReceipt);

    assertEquals(eventValuesWithLogs2.size(), 1);
    assertEquals(eventValuesWithLogs2.get(0).getLog(), logs.get(1));
}
 
Example #24
Source File: ResponseTest.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testTransactionReceiptIsStatusOK() {
    TransactionReceipt transactionReceipt = new TransactionReceipt();
    transactionReceipt.setStatus("0x1");
    assertThat(transactionReceipt.isStatusOK(), equalTo(true));

    TransactionReceipt transactionReceiptNoStatus = new TransactionReceipt();
    assertThat(transactionReceiptNoStatus.isStatusOK(), equalTo(true));

    TransactionReceipt transactionReceiptZeroStatus = new TransactionReceipt();
    transactionReceiptZeroStatus.setStatus("0x0");
    assertThat(transactionReceiptZeroStatus.isStatusOK(), equalTo(false));
}
 
Example #25
Source File: Transfer.java    From web3j with Apache License 2.0 5 votes vote down vote up
public static RemoteCall<TransactionReceipt> sendFunds(
        Web3j web3j,
        Credentials credentials,
        String toAddress,
        BigDecimal value,
        Convert.Unit unit)
        throws InterruptedException, IOException, TransactionException {

    TransactionManager transactionManager = new RawTransactionManager(web3j, credentials);

    return new RemoteCall<>(
            () -> new Transfer(web3j, transactionManager).send(toAddress, value, unit));
}
 
Example #26
Source File: ENS.java    From web3j with Apache License 2.0 5 votes vote down vote up
public List<NewResolverEventResponse> getNewResolverEvents(TransactionReceipt transactionReceipt) {
    List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(NEWRESOLVER_EVENT, transactionReceipt);
    ArrayList<NewResolverEventResponse> responses = new ArrayList<NewResolverEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        NewResolverEventResponse typedResponse = new NewResolverEventResponse();
        typedResponse.log = eventValues.getLog();
        typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
        typedResponse.resolver = (String) eventValues.getNonIndexedValues().get(0).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #27
Source File: Purchase.java    From web3j with Apache License 2.0 5 votes vote down vote up
public List<ItemReceivedEventResponse> getItemReceivedEvents(TransactionReceipt transactionReceipt) {
    List<EventValuesWithLog> valueList = extractEventParametersWithLog(ITEMRECEIVED_EVENT, transactionReceipt);
    ArrayList<ItemReceivedEventResponse> responses = new ArrayList<ItemReceivedEventResponse>(valueList.size());
    for (Contract.EventValuesWithLog eventValues : valueList) {
        ItemReceivedEventResponse typedResponse = new ItemReceivedEventResponse();
        typedResponse.log = eventValues.getLog();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #28
Source File: Greeting.java    From tutorials with MIT License 5 votes vote down vote up
public RemoteCall<TransactionReceipt> setGreeting(String _message) {
    final Function function = new Function(
            "setGreeting",
            Arrays.<Type>asList(new org.web3j.abi.datatypes.Utf8String(_message)),
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example #29
Source File: PublicResolver.java    From etherscan-explorer with GNU General Public License v3.0 5 votes vote down vote up
public List<ABIChangedEventResponse> getABIChangedEvents(TransactionReceipt transactionReceipt) {
    final Event event = new Event("ABIChanged", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>() {}, new TypeReference<Uint256>() {}),
            Arrays.<TypeReference<?>>asList());
    List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
    ArrayList<ABIChangedEventResponse> responses = new ArrayList<ABIChangedEventResponse>(valueList.size());
    for (EventValues eventValues : valueList) {
        ABIChangedEventResponse typedResponse = new ABIChangedEventResponse();
        typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
        typedResponse.contentType = (BigInteger) eventValues.getIndexedValues().get(1).getValue();
        responses.add(typedResponse);
    }
    return responses;
}
 
Example #30
Source File: ContractTest.java    From web3j with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeploy() throws Exception {
    TransactionReceipt transactionReceipt = createTransactionReceipt();
    Contract deployedContract = deployContract(transactionReceipt);

    assertEquals(ADDRESS, deployedContract.getContractAddress());
    assertTrue(deployedContract.getTransactionReceipt().isPresent());
    assertEquals(transactionReceipt, deployedContract.getTransactionReceipt().get());
}