org.fisco.bcos.web3j.protocol.Web3j Java Examples
The following examples show how to use
org.fisco.bcos.web3j.protocol.Web3j.
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: Contract.java From web3sdk with Apache License 2.0 | 6 votes |
@Deprecated protected Contract( String contractBinary, String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { this( contractBinary, contractAddress, web3j, getTheTransactionManager(web3j, credentials), gasPrice, gasLimit); }
Example #2
Source File: TransService.java From WeBASE-Front with Apache License 2.0 | 6 votes |
/** * send tx with sign for precomnpiled contract * * @param precompiledType enum of precompiled contract * @param funcName precompiled contract function name */ public Object transHandleWithSignForPrecompile(int groupId, String signUserId, PrecompiledTypes precompiledType, String funcName, List<Object> funcParams) throws Exception { // check groupId Web3j web3j = web3ApiService.getWeb3j(groupId); // get address and abi of precompiled contract String contractAddress = PrecompiledCommonInfo.getAddress(precompiledType); String abiStr = PrecompiledCommonInfo.getAbi(precompiledType); List<Object> contractAbi = JsonUtils.toJavaObjectList(abiStr, Object.class); // check function param and get function param from abi ContractFunction contractFunction = buildContractFunctionWithAbi(contractAbi, funcName, funcParams); // encode function Function function = new Function(funcName, contractFunction.getFinalInputs(), contractFunction.getFinalOutputs()); // trans handle return handleTransByFunction(groupId, web3j, signUserId, contractAddress, function, contractFunction); }
Example #3
Source File: Contract.java From web3sdk with Apache License 2.0 | 6 votes |
@Deprecated protected static <T extends Contract> T deploy( Class<T> type, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, String binary, String encodedConstructor, BigInteger value) throws RuntimeException, TransactionException { return deploy( type, web3j, credentials, new StaticGasProvider(gasPrice, gasLimit), binary, encodedConstructor, value); }
Example #4
Source File: Web3SDK2Wrapper.java From WeEvent with Apache License 2.0 | 6 votes |
private static Map<String, Map<String, String>> getBlockNums(Web3j web3j) throws IOException { JsonNode jsonObj = JsonHelper.getObjectMapper().readTree(web3j.getSyncStatus().sendForReturnString()); Map<String, Map<String, String>> nodeBlockNums = new HashMap<>(); Map<String, String> map = new HashMap<>(); jsonObj.fields().forEachRemaining(entry -> { if (BLOCK_NUMBER.equals(entry.getKey()) || NODE_ID.equals(entry.getKey())) { map.put(entry.getKey(), entry.getValue().asText()); } if (PEERS.equals(entry.getKey())) { convertJsonArrayToList(nodeBlockNums, entry.getValue()); } }); nodeBlockNums.put(jsonObj.get(NODE_ID).asText(), map); return nodeBlockNums; }
Example #5
Source File: TestGroupSig.java From group-signature-client with GNU General Public License v3.0 | 6 votes |
@Deprecated public static RemoteCall<TestGroupSig> deploy( Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, String _sig, String _message, String _gpk_info, String _pbc_param_info) { String encodedConstructor = FunctionEncoder.encodeConstructor( Arrays.<Type>asList( new Utf8String(_sig), new Utf8String(_message), new Utf8String(_gpk_info), new Utf8String(_pbc_param_info))); return deployRemoteCall( TestGroupSig.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor); }
Example #6
Source File: TestGroupSig.java From group-signature-client with GNU General Public License v3.0 | 6 votes |
public static RemoteCall<TestGroupSig> deploy( Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider, String _sig, String _message, String _gpk_info, String _pbc_param_info) { String encodedConstructor = FunctionEncoder.encodeConstructor( Arrays.<Type>asList( new Utf8String(_sig), new Utf8String(_message), new Utf8String(_gpk_info), new Utf8String(_pbc_param_info))); return deployRemoteCall( TestGroupSig.class, web3j, transactionManager, contractGasProvider, BINARY, encodedConstructor); }
Example #7
Source File: MockBlockTest.java From web3sdk with Apache License 2.0 | 6 votes |
@Test public void getBlockNumber() throws IOException { BcosBlock block = objectMapper.readValue(rawResponse, BcosBlock.class); block.setRawResponse(rawResponse); Web3j web3j = Web3j.build(web3jService); when(web3jService.send(any(Request.class), eq(BcosBlock.class))).thenReturn(block); BcosBlock mockBlocks = web3j.getBlockByNumber(DefaultBlockParameter.valueOf(new BigInteger("1")), true) .send(); BcosBlock.Block mockBlock = mockBlocks.getBlock(); assertEquals(mockBlock.getNonce(), new BigInteger("0")); assertTrue(mockBlock.getNumber().intValue() == 1); }
Example #8
Source File: Contract.java From web3sdk with Apache License 2.0 | 6 votes |
public static <T extends Contract> RemoteCall<T> deployRemoteCall( Class<T> type, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider, String binary, String encodedConstructor, BigInteger value) { return new RemoteCall<>( () -> deploy( type, web3j, credentials, contractGasProvider, binary, encodedConstructor, value)); }
Example #9
Source File: CRUDService.java From web3sdk with Apache License 2.0 | 5 votes |
public CRUDService(Web3j web3j, Credentials credentials) { ContractGasProvider contractGasProvider = new StaticGasProvider(gasPrice, gasLimit); tableFactory = TableFactory.load( TableFactoryPrecompileAddress, web3j, credentials, contractGasProvider); crud = CRUD.load(CRUDPrecompileAddress, web3j, credentials, contractGasProvider); }
Example #10
Source File: RingSigPrecompiled.java From group-signature-client with GNU General Public License v3.0 | 5 votes |
@Deprecated public static RingSigPrecompiled load( String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { return new RingSigPrecompiled( contractAddress, web3j, transactionManager, gasPrice, gasLimit); }
Example #11
Source File: MixContractClient.java From web3sdk with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { // init the Service ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml"); Service service = context.getBean(Service.class); service.setGroupId(Integer.parseInt(args[0])); service.run(); // run the daemon service // init the client keys keyPair = Keys.createEcKeyPair(); credentials = Credentials.create(keyPair); logger.info("-----> start test !"); logger.info("init AOMP ChannelEthereumService"); ChannelEthereumService channelEthereumService = new ChannelEthereumService(); channelEthereumService.setChannelService(service); try { web3j = Web3j.build(channelEthereumService, Integer.parseInt(args[0])); } catch (Exception e) { System.out.println("\nPlease provide groupID in the first paramters"); System.exit(0); } if (args.length > 1) { if ("deploy".equals(args[1])) { deploymixContract(); } else { String[] params = new String[args.length - 1]; for (int i = 0; i < params.length; i++) params[i] = args[i + 1]; testMixContract(params); } } else { System.out.println( "\nPlease choose follow commands:\n deploy, create, insert, select, update or remove"); } System.exit(0); }
Example #12
Source File: MixContract.java From web3sdk with Apache License 2.0 | 5 votes |
public static MixContract load( String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { return new MixContract(contractAddress, web3j, transactionManager, contractGasProvider); }
Example #13
Source File: TableTest.java From web3sdk with Apache License 2.0 | 5 votes |
protected TableTest( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); }
Example #14
Source File: TestGroupSig.java From group-signature-client with GNU General Public License v3.0 | 5 votes |
protected TestGroupSig( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); }
Example #15
Source File: ParallelOk.java From web3sdk with Apache License 2.0 | 5 votes |
public static RemoteCall<ParallelOk> deploy( Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { return deployRemoteCall( ParallelOk.class, web3j, transactionManager, contractGasProvider, getBinary(), ""); }
Example #16
Source File: Ok.java From WeBASE-Front with Apache License 2.0 | 5 votes |
public static Ok load( String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { return new Ok(contractAddress, web3j, transactionManager, contractGasProvider); }
Example #17
Source File: TableTest.java From web3sdk with Apache License 2.0 | 5 votes |
@Deprecated protected TableTest( String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); }
Example #18
Source File: Ok.java From web3sdk with Apache License 2.0 | 5 votes |
@Deprecated public static RemoteCall<Ok> deploy( Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { return deployRemoteCall( Ok.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, ""); }
Example #19
Source File: OkD.java From web3sdk with Apache License 2.0 | 5 votes |
public static OkD load( String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { return new OkD(contractAddress, web3j, transactionManager, contractGasProvider); }
Example #20
Source File: CRUD.java From web3sdk with Apache License 2.0 | 5 votes |
@Deprecated protected CRUD( String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); }
Example #21
Source File: Permission.java From web3sdk with Apache License 2.0 | 5 votes |
@Deprecated protected Permission( String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { super(getBinary(), contractAddress, web3j, transactionManager, gasPrice, gasLimit); }
Example #22
Source File: Evidence.java From WeBASE-Front with Apache License 2.0 | 5 votes |
@Deprecated public static RemoteCall<Evidence> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, String evi, String info, String id, BigInteger v, byte[] r, byte[] s, String addr, String sender) { String encodedConstructor = FunctionEncoder.encodeConstructor(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), new org.fisco.bcos.web3j.abi.datatypes.Address(addr), new org.fisco.bcos.web3j.abi.datatypes.Address(sender))); return deployRemoteCall(Evidence.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor); }
Example #23
Source File: Ok.java From WeBASE-Front with Apache License 2.0 | 5 votes |
@Deprecated protected Ok( String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); }
Example #24
Source File: DagTransfer.java From web3sdk with Apache License 2.0 | 5 votes |
protected DagTransfer( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { super(getBinary(), contractAddress, web3j, credentials, contractGasProvider); }
Example #25
Source File: Ok.java From web3sdk with Apache License 2.0 | 5 votes |
public static Ok load( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { return new Ok(contractAddress, web3j, credentials, contractGasProvider); }
Example #26
Source File: TableFactory.java From web3sdk with Apache License 2.0 | 5 votes |
protected TableFactory( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); }
Example #27
Source File: Ok.java From web3sdk with Apache License 2.0 | 5 votes |
public static RemoteCall<Ok> deploy( Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { return deployRemoteCall( Ok.class, web3j, transactionManager, contractGasProvider, BINARY, ""); }
Example #28
Source File: Ok.java From web3sdk with Apache License 2.0 | 5 votes |
@Deprecated public static Ok load( String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { return new Ok(contractAddress, web3j, credentials, gasPrice, gasLimit); }
Example #29
Source File: OkD.java From web3sdk with Apache License 2.0 | 5 votes |
@Deprecated public static OkD load( String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { return new OkD(contractAddress, web3j, transactionManager, gasPrice, gasLimit); }
Example #30
Source File: CNS.java From web3sdk with Apache License 2.0 | 5 votes |
@Deprecated public static CNS load( String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { return new CNS(contractAddress, web3j, transactionManager, gasPrice, gasLimit); }