org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt Java Examples
The following examples show how to use
org.fisco.bcos.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: TestGroupSig.java From group-signature-client with GNU General Public License v3.0 | 6 votes |
public Tuple4<String, String, String, String> getUpdate_group_sig_dataInput( TransactionReceipt transactionReceipt) { String data = transactionReceipt.getInput().substring(10); final Function function = new Function( FUNC_UPDATE_GROUP_SIG_DATA, Arrays.<Type>asList(), Arrays.<TypeReference<?>>asList( new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {})); List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters()); ; return new Tuple4<String, String, String, String>( (String) results.get(0).getValue(), (String) results.get(1).getValue(), (String) results.get(2).getValue(), (String) results.get(3).getValue()); }
Example #2
Source File: Evidence.java From evidenceSample with Apache License 2.0 | 6 votes |
public List<AddSignaturesEventEventResponse> getAddSignaturesEventEvents(TransactionReceipt transactionReceipt) { List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(ADDSIGNATURESEVENT_EVENT, transactionReceipt); ArrayList<AddSignaturesEventEventResponse> responses = new ArrayList<AddSignaturesEventEventResponse>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { AddSignaturesEventEventResponse typedResponse = new AddSignaturesEventEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.evi = (String) eventValues.getNonIndexedValues().get(0).getValue(); typedResponse.info = (String) eventValues.getNonIndexedValues().get(1).getValue(); typedResponse.id = (String) eventValues.getNonIndexedValues().get(2).getValue(); typedResponse.v = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); typedResponse.r = (byte[]) eventValues.getNonIndexedValues().get(4).getValue(); typedResponse.s = (byte[]) eventValues.getNonIndexedValues().get(5).getValue(); responses.add(typedResponse); } return responses; }
Example #3
Source File: Contract.java From web3sdk with Apache License 2.0 | 6 votes |
private static <T extends Contract> T create( T contract, String binary, String encodedConstructor, BigInteger value) throws IOException, TransactionException { TransactionReceipt transactionReceipt = contract.executeTransaction(binary + encodedConstructor, value, FUNC_DEPLOY); String contractAddress = transactionReceipt.getContractAddress(); if (contractAddress == null) { throw new RuntimeException("Empty contract address returned"); } contract.setContractAddress(contractAddress); contract.setTransactionReceipt(transactionReceipt); return contract; }
Example #4
Source File: Evidence.java From evidenceSample with Apache License 2.0 | 6 votes |
public List<ErrorAddSignaturesEventEventResponse> getErrorAddSignaturesEventEvents(TransactionReceipt transactionReceipt) { List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(ERRORADDSIGNATURESEVENT_EVENT, transactionReceipt); ArrayList<ErrorAddSignaturesEventEventResponse> responses = new ArrayList<ErrorAddSignaturesEventEventResponse>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { ErrorAddSignaturesEventEventResponse typedResponse = new ErrorAddSignaturesEventEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.evi = (String) eventValues.getNonIndexedValues().get(0).getValue(); typedResponse.info = (String) eventValues.getNonIndexedValues().get(1).getValue(); typedResponse.id = (String) eventValues.getNonIndexedValues().get(2).getValue(); typedResponse.v = (BigInteger) eventValues.getNonIndexedValues().get(3).getValue(); typedResponse.r = (byte[]) eventValues.getNonIndexedValues().get(4).getValue(); typedResponse.s = (byte[]) eventValues.getNonIndexedValues().get(5).getValue(); typedResponse.addr = (String) eventValues.getNonIndexedValues().get(6).getValue(); responses.add(typedResponse); } return responses; }
Example #5
Source File: TransController.java From WeBASE-Front with Apache License 2.0 | 6 votes |
@ApiOperation(value = "send signed transaction ") @ApiImplicitParam(name = "reqSignedTransHandle", value = "transaction info", required = true, dataType = "ReqSignedTransHandle") @PostMapping("/signed-transaction") public TransactionReceipt sendSignedTransaction(@Valid @RequestBody ReqSignedTransHandle reqSignedTransHandle, BindingResult result) throws Exception { log.info("transHandleLocal start. ReqSignedTransHandle:[{}]", JsonUtils.toJSONString(reqSignedTransHandle)); Instant startTime = Instant.now(); log.info("transHandleLocal start startTime:{}", startTime.toEpochMilli()); checkParamResult(result); String signedStr = reqSignedTransHandle.getSignedStr(); if (StringUtils.isBlank(signedStr)) { throw new FrontException(ENCODE_STR_CANNOT_BE_NULL); } TransactionReceipt receipt = transServiceImpl.sendSignedTransaction(signedStr, reqSignedTransHandle.getSync(),reqSignedTransHandle.getGroupId()); log.info("transHandleLocal end useTime:{}", Duration.between(startTime, Instant.now()).toMillis()); return receipt; }
Example #6
Source File: FiscoBcos2.java From WeEvent with Apache License 2.0 | 6 votes |
/** * Get a TransactionReceipt request from a transaction Hash. * * @param transactionHash the transactionHash value * @return the transactionReceipt wrapper */ private Optional<TransactionReceipt> getTransactionReceiptRequest(String transactionHash) { Optional<TransactionReceipt> receiptOptional = Optional.empty(); try { for (int i = 0; i < WeEventConstants.POLL_TRANSACTION_ATTEMPTS; i++) { receiptOptional = web3j.getTransactionReceipt(transactionHash).send().getTransactionReceipt(); if (!receiptOptional.isPresent()) { Thread.sleep(this.fiscoConfig.getConsumerIdleTime()); } else { return receiptOptional; } } } catch (IOException | InterruptedException e) { log.error("get transactionReceipt failed.", e); } return receiptOptional; }
Example #7
Source File: TransService.java From WeBASE-Front with Apache License 2.0 | 6 votes |
/** * execTransaction through common contract * * @param function function * @param commonContract contract */ public static TransactionReceipt execTransaction(Function function, CommonContract commonContract) throws FrontException { TransactionReceipt transactionReceipt = null; Instant startTime = Instant.now(); log.info("execTransaction start startTime:{}", startTime.toEpochMilli()); try { transactionReceipt = commonContract.execTransaction(function); } catch (IOException | TransactionException | ContractCallException e) { log.error("execTransaction failed.", e); throw new FrontException(ConstantCode.TRANSACTION_SEND_FAILED.getCode(), e.getMessage()); } log.info("execTransaction end useTime:{}", Duration.between(startTime, Instant.now()).toMillis()); return transactionReceipt; }
Example #8
Source File: ContractAbiUtil.java From WeBASE-Transaction with Apache License 2.0 | 6 votes |
/** * receiptParse. * * @param receipt info * @param abiList info * @return */ public static Object receiptParse(TransactionReceipt receipt, List<AbiDefinition> abiList) throws BaseException { Map<String, Object> resultMap = new HashMap<>(); List<Log> logList = receipt.getLogs(); for (AbiDefinition abiDefinition : abiList) { String eventName = abiDefinition.getName(); List<String> funcInputTypes = getFuncInputType(abiDefinition); List<TypeReference<?>> finalOutputs = outputFormat(funcInputTypes); Event event = new Event(eventName, finalOutputs); Object result = null; for (Log logInfo : logList) { EventValues eventValues = Contract.staticExtractEventParameters(event, logInfo); if (eventValues != null) { result = callResultParse(funcInputTypes, eventValues.getNonIndexedValues()); break; } } if (result != null) { resultMap.put(eventName, result); } } return resultMap; }
Example #9
Source File: NewSolTest.java From web3sdk with Apache License 2.0 | 6 votes |
public List<OwnershipTransferredEventResponse> getOwnershipTransferredEvents( TransactionReceipt transactionReceipt) { List<EventValuesWithLog> valueList = extractEventParametersWithLog(OWNERSHIPTRANSFERRED_EVENT, transactionReceipt); ArrayList<OwnershipTransferredEventResponse> responses = new ArrayList<OwnershipTransferredEventResponse>(valueList.size()); for (EventValuesWithLog eventValues : valueList) { OwnershipTransferredEventResponse typedResponse = new OwnershipTransferredEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse._from = (String) eventValues.getIndexedValues().get(0).getValue(); typedResponse._to = (String) eventValues.getIndexedValues().get(1).getValue(); responses.add(typedResponse); } return responses; }
Example #10
Source File: EvidenceVerify.java From web3sdk with Apache License 2.0 | 6 votes |
public RemoteCall<TransactionReceipt> insertEvidence( String evi, String info, String id, String signAddr, byte[] message, BigInteger v, byte[] r, byte[] s) { final Function function = new Function( FUNC_INSERTEVIDENCE, Arrays.<Type>asList( new org.fisco.bcos.web3j.abi.datatypes.Utf8String(evi), new org.fisco.bcos.web3j.abi.datatypes.Utf8String(info), new org.fisco.bcos.web3j.abi.datatypes.Utf8String(id), new org.fisco.bcos.web3j.abi.datatypes.Address(signAddr), new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(message), new org.fisco.bcos.web3j.abi.datatypes.generated.Uint8(v), new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(r), new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(s)), Collections.<TypeReference<?>>emptyList()); return executeRemoteCallTransaction(function); }
Example #11
Source File: BlockTxDetailInfoDAO.java From WeBASE-Collect-Bee with Apache License 2.0 | 5 votes |
/** * Get block transaction detail info from transaction receipt object and insert BlockTxDetailInfo into db. * * @param receipt : TransactionReceipt * @param blockTimeStamp * @param contractName: contract name * @param methodName: method name * @return void * @throws IOException */ public void save(TransactionReceipt receipt, BigInteger blockTimeStamp, String contractName, String methodName) throws IOException { BlockTxDetailInfo blockTxDetailInfo = new BlockTxDetailInfo(); blockTxDetailInfo.setBlockHash(receipt.getBlockHash()); blockTxDetailInfo.setBlockHeight(receipt.getBlockNumber().longValue()); blockTxDetailInfo.setContractName(contractName); blockTxDetailInfo.setMethodName(methodName.substring(contractName.length())); Transaction transaction = ethClient.getTransactionByHash(receipt).get(); blockTxDetailInfo.setTxFrom(transaction.getFrom()); blockTxDetailInfo.setTxTo(transaction.getTo()); blockTxDetailInfo.setTxHash(receipt.getTransactionHash()); blockTxDetailInfo.setBlockTimeStamp(new Date(blockTimeStamp.longValue())); blockTxDetailInfoRepository.save(blockTxDetailInfo); }
Example #12
Source File: TableTest.java From web3sdk with Apache License 2.0 | 5 votes |
public List<CreateResultEventResponse> getCreateResultEvents( TransactionReceipt transactionReceipt) { List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(CREATERESULT_EVENT, transactionReceipt); ArrayList<CreateResultEventResponse> responses = new ArrayList<CreateResultEventResponse>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { CreateResultEventResponse typedResponse = new CreateResultEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.count = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); responses.add(typedResponse); } return responses; }
Example #13
Source File: ManagedTransactionTester.java From web3sdk with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") void prepareTransactionReceipt(TransactionReceipt transactionReceipt) throws IOException { BcosTransactionReceipt ethGetTransactionReceipt = new BcosTransactionReceipt(); ethGetTransactionReceipt.setResult(transactionReceipt); Request<?, BcosTransactionReceipt> getTransactionReceiptRequest = mock(Request.class); when(getTransactionReceiptRequest.send()).thenReturn(ethGetTransactionReceipt); when(web3j.getTransactionReceipt(TRANSACTION_HASH)) .thenReturn((Request) getTransactionReceiptRequest); }
Example #14
Source File: AccountInfoDAO.java From WeBASE-Collect-Bee with Apache License 2.0 | 5 votes |
/** * Get account info from transaction receipt and insert AccountInfo object into db. * * @param receipt:TransactionReceipt * @param blockTimeStamp: block timestamp * @param contractName: contract name * @return void */ public void save(TransactionReceipt receipt, BigInteger blockTimeStamp, String contractName) { AccountInfo accountInfo = new AccountInfo(); accountInfo.setBlockHeight(receipt.getBlockNumber().longValue()); accountInfo.setBlockTimeStamp(new Date(blockTimeStamp.longValue())); accountInfo.setContractAddress(receipt.getContractAddress()); accountInfo.setContractName(contractName); accountInfoRepository.save(accountInfo); }
Example #15
Source File: Topic.java From WeEvent with Apache License 2.0 | 5 votes |
public Tuple2<String, String> getDelOperatorInput(TransactionReceipt transactionReceipt) { String data = transactionReceipt.getInput().substring(10); final Function function = new Function(FUNC_DELOPERATOR, Arrays.<Type>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Address>() {})); List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());; return new Tuple2<String, String>( (String) results.get(0).getValue(), (String) results.get(1).getValue() ); }
Example #16
Source File: ParallelOk.java From web3sdk with Apache License 2.0 | 5 votes |
public RemoteCall<TransactionReceipt> set(String name, BigInteger num) { final Function function = new Function( FUNC_SET, Arrays.<Type>asList( new org.fisco.bcos.web3j.abi.datatypes.Utf8String(name), new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(num)), Collections.<TypeReference<?>>emptyList()); return executeRemoteCallTransaction(function); }
Example #17
Source File: TestRingSig.java From group-signature-client with GNU General Public License v3.0 | 5 votes |
public RemoteCall<TransactionReceipt> update_ring_sig_data( String new_sig, String new_message, String new_param_info) { final Function function = new Function( FUNC_UPDATE_RING_SIG_DATA, Arrays.<Type>asList( new Utf8String(new_sig), new Utf8String(new_message), new Utf8String(new_param_info)), Collections.<TypeReference<?>>emptyList()); return executeRemoteCallTransaction(function); }
Example #18
Source File: DagTransfer.java From web3sdk with Apache License 2.0 | 5 votes |
public RemoteCall<TransactionReceipt> userTransfer( String user_a, String user_b, BigInteger amount) { final Function function = new Function( FUNC_USERTRANSFER, Arrays.<Type>asList( new org.fisco.bcos.web3j.abi.datatypes.Utf8String(user_a), new org.fisco.bcos.web3j.abi.datatypes.Utf8String(user_b), new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(amount)), Collections.<TypeReference<?>>emptyList()); return executeRemoteCallTransaction(function); }
Example #19
Source File: ContractLifeCyclePrecompiled.java From web3sdk with Apache License 2.0 | 5 votes |
public Tuple1<BigInteger> getGrantManagerOutput(TransactionReceipt transactionReceipt) { String data = transactionReceipt.getOutput(); final Function function = new Function( FUNC_GRANTMANAGER, Arrays.<Type>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<Int256>() {})); List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters()); ; return new Tuple1<BigInteger>((BigInteger) results.get(0).getValue()); }
Example #20
Source File: ContractLifeCyclePrecompiled.java From web3sdk with Apache License 2.0 | 5 votes |
public RemoteCall<TransactionReceipt> freeze(String addr) { final Function function = new Function( FUNC_FREEZE, Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Address(addr)), Collections.<TypeReference<?>>emptyList()); return executeRemoteCallTransaction(function); }
Example #21
Source File: Permission.java From web3sdk with Apache License 2.0 | 5 votes |
public Tuple2<String, String> getGrantWriteInput(TransactionReceipt transactionReceipt) { String data = transactionReceipt.getInput().substring(10); final Function function = new Function( FUNC_GRANTWRITE, Arrays.<Type>asList(), Arrays.<TypeReference<?>>asList( new TypeReference<Address>() {}, new TypeReference<Address>() {})); List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters()); ; return new Tuple2<String, String>( (String) results.get(0).getValue(), (String) results.get(1).getValue()); }
Example #22
Source File: Permission.java From web3sdk with Apache License 2.0 | 5 votes |
public Tuple1<BigInteger> getRemoveOutput(TransactionReceipt transactionReceipt) { String data = transactionReceipt.getOutput(); final Function function = new Function( FUNC_REMOVE, Arrays.<Type>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<Int256>() {})); List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters()); ; return new Tuple1<BigInteger>((BigInteger) results.get(0).getValue()); }
Example #23
Source File: HelloWorldGM.java From WeBASE-Front with Apache License 2.0 | 5 votes |
public RemoteCall<TransactionReceipt> set(String n) { final Function function = new Function( FUNC_SET, Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(n)), Collections.<TypeReference<?>>emptyList()); return executeRemoteCallTransaction(function); }
Example #24
Source File: PerformanceHelloWorldCallback.java From WeBASE-Front with Apache License 2.0 | 5 votes |
@Override public void onResponse(TransactionReceipt receipt) { Long cost = System.currentTimeMillis() - startTime; try { collector.onMessage(receipt, cost); } catch (Exception e) { logger.error("onMessage error: ", e); } }
Example #25
Source File: Ok.java From WeBASE-Front with Apache License 2.0 | 5 votes |
public List<TransEventEventResponse> getTransEventEvents(TransactionReceipt transactionReceipt) { List<EventValuesWithLog> valueList = extractEventParametersWithLog(TRANSEVENT_EVENT, transactionReceipt); ArrayList<TransEventEventResponse> responses = new ArrayList<TransEventEventResponse>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { TransEventEventResponse typedResponse = new TransEventEventResponse(); typedResponse.log = eventValues.getLog(); typedResponse.num = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); responses.add(typedResponse); } return responses; }
Example #26
Source File: Ok.java From WeBASE-Front with Apache License 2.0 | 5 votes |
public RemoteCall<TransactionReceipt> trans(BigInteger num) { final Function function = new Function( FUNC_TRANS, Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.generated.Uint256(num)), Collections.<TypeReference<?>>emptyList()); return executeRemoteCallTransaction(function); }
Example #27
Source File: EvidenceSignersData.java From evidenceSample with Apache License 2.0 | 5 votes |
public RemoteCall<TransactionReceipt> newEvidence(String evi, String info, String id, BigInteger v, byte[] r, byte[] s) { final Function function = new Function( FUNC_NEWEVIDENCE, Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(evi), new org.fisco.bcos.web3j.abi.datatypes.Utf8String(info), new org.fisco.bcos.web3j.abi.datatypes.Utf8String(id), new org.fisco.bcos.web3j.abi.datatypes.generated.Uint8(v), new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(r), new org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32(s)), Collections.<TypeReference<?>>emptyList()); return executeRemoteCallTransaction(function); }
Example #28
Source File: EvidenceVerify.java From web3sdk with Apache License 2.0 | 5 votes |
public Tuple8<String, String, String, String, byte[], BigInteger, byte[], byte[]> getInsertEvidenceInput(TransactionReceipt transactionReceipt) { String data = transactionReceipt.getInput().substring(10); final Function function = new Function( FUNC_INSERTEVIDENCE, Arrays.<Type>asList(), Arrays.<TypeReference<?>>asList( new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Address>() {}, new TypeReference<Bytes32>() {}, new TypeReference<Uint8>() {}, new TypeReference<Bytes32>() {}, new TypeReference<Bytes32>() {})); List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters()); ; return new Tuple8<String, String, String, String, byte[], BigInteger, byte[], byte[]>( (String) results.get(0).getValue(), (String) results.get(1).getValue(), (String) results.get(2).getValue(), (String) results.get(3).getValue(), (byte[]) results.get(4).getValue(), (BigInteger) results.get(5).getValue(), (byte[]) results.get(6).getValue(), (byte[]) results.get(7).getValue()); }
Example #29
Source File: ChainGovernance.java From web3sdk with Apache License 2.0 | 5 votes |
public Tuple1<BigInteger> getGrantOperatorOutput(TransactionReceipt transactionReceipt) { String data = transactionReceipt.getOutput(); final Function function = new Function( FUNC_GRANTOPERATOR, Arrays.<Type>asList(), Arrays.<TypeReference<?>>asList(new TypeReference<Int256>() {})); List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters()); ; return new Tuple1<BigInteger>((BigInteger) results.get(0).getValue()); }
Example #30
Source File: TransHashController.java From WeBASE-Node-Manager with Apache License 2.0 | 5 votes |
/** * get transaction receipt. */ @GetMapping("/transactionReceipt/{groupId}/{transHash}") public BaseResponse getTransReceipt(@PathVariable("groupId") Integer groupId, @PathVariable("transHash") String transHash) throws NodeMgrException { Instant startTime = Instant.now(); log.info("start getTransReceipt startTime:{} groupId:{} transaction:{}", startTime.toEpochMilli(), groupId, transHash); BaseResponse baseResponse = new BaseResponse(ConstantCode.SUCCESS); TransactionReceipt transReceipt = transHashService.getTransReceipt(groupId, transHash); baseResponse.setData(transReceipt); log.info("end getTransReceipt useTime:{} result:{}", Duration.between(startTime, Instant.now()).toMillis(), JsonTools.toJSONString(baseResponse)); return baseResponse; }