org.fisco.bcos.web3j.crypto.Credentials Java Examples
The following examples show how to use
org.fisco.bcos.web3j.crypto.Credentials.
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: FiscoBcosBroker4ProducerTest.java From WeEvent with Apache License 2.0 | 6 votes |
/** * publish an externally signed event by external account. */ @Test public void testPublishByExternalAccountNoPermission() throws Exception { Map<String, String> ext = new HashMap<>(); ext.put(WeEvent.WeEvent_SIGN, "true"); WeEvent event = new WeEvent(this.topicName, "this is a signed message".getBytes(), ext); String rawData = buildWeEvent(event); ExtendedRawTransaction rawTransaction = getRawTransaction(this.groupId, rawData, this.contractContext); Credentials credentials = getExternalAccountCredentials(); String signData = signData(rawTransaction, credentials); SendResult sendResult = this.iProducer.publish(new WeEvent(this.topicName, signData.getBytes(), ext), this.groupId).get(transactionTimeout, TimeUnit.MILLISECONDS); Assert.assertEquals(sendResult.getStatus(), SendResult.SendResultStatus.NO_PERMISSION); }
Example #2
Source File: ConsensusServiceTest.java From WeBASE-Front with Apache License 2.0 | 6 votes |
@Test public void testConsensus() throws Exception { nodeId = "224e6ee23e8a02d371298b9aec828f77cc2711da3a981684896715a3711885a3177b3cf7906bf9d1b84e597fad1e0049511139332c04edfe3daddba5ed60cffa"; context = new ClassPathXmlApplicationContext("applicationContext.xml"); PEMManager pem = context.getBean(PEMManager.class); ECKeyPair pemKeyPair = pem.getECKeyPair(); //链管理员私钥加载 Credentials credentialsPEM = GenCredential.create(pemKeyPair.getPrivateKey().toString(16)); ConsensusService consensusService = new ConsensusService(web3j, credentialsPEM); System.out.println(consensusService.addSealer(nodeId)); assertNotNull(consensusService.addSealer(nodeId)); System.out.println(consensusService.addObserver(nodeId)); assertNotNull(consensusService.addObserver(nodeId)); System.out.println(consensusService.removeNode(nodeId)); assertNotNull(consensusService.removeNode(nodeId)); }
Example #3
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, BigInteger gasPrice, BigInteger gasLimit, String binary, String encodedConstructor, BigInteger value) { return new RemoteCall<>( () -> deploy( type, web3j, credentials, gasPrice, gasLimit, binary, encodedConstructor, value)); }
Example #4
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, BigInteger gasPrice, BigInteger gasLimit, String binary, String encodedConstructor) { return deployRemoteCall( type, web3j, credentials, gasPrice, gasLimit, binary, encodedConstructor, BigInteger.ZERO); }
Example #5
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 #6
Source File: ManagedTransactionTester.java From web3sdk with Apache License 2.0 | 5 votes |
public TransactionManager getVerifiedTransactionManager( Credentials credentials, int attempts, int sleepDuration) { RawTransactionManager transactionManager = new RawTransactionManager(web3j, credentials, attempts, sleepDuration); transactionManager.setTxHashVerifier(txHashVerifier); return transactionManager; }
Example #7
Source File: Permission.java From web3sdk with Apache License 2.0 | 5 votes |
@Deprecated protected Permission( String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { super(getBinary(), contractAddress, web3j, credentials, gasPrice, gasLimit); }
Example #8
Source File: ContractLifeCyclePrecompiled.java From web3sdk with Apache License 2.0 | 5 votes |
protected ContractLifeCyclePrecompiled( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); }
Example #9
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 #10
Source File: NewSolTest.java From web3sdk with Apache License 2.0 | 5 votes |
protected NewSolTest( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); }
Example #11
Source File: NewSolTest.java From web3sdk with Apache License 2.0 | 5 votes |
public static NewSolTest load( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { return new NewSolTest(contractAddress, web3j, credentials, contractGasProvider); }
Example #12
Source File: CnsServiceTest.java From WeBASE-Front with Apache License 2.0 | 5 votes |
@Test public void testRegCns() throws Exception { contractName = "Evidence1"; version = "1.0"; address = "0x8acf30e511c885163b8b9d85f34b806c216da6cc"; abi = "{\"constant\":true,\"inputs\":[{\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"get\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"id\",\"type\":\"bytes32\"},{\"name\":\"decription\",\"type\":\"string\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"evidence\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]"; contractNameAndVersion = "Evidencee:1.0"; context = new ClassPathXmlApplicationContext("applicationContext.xml"); PEMManager pem = context.getBean(PEMManager.class); ECKeyPair pemKeyPair = pem.getECKeyPair(); //链管理员私钥加载 Credentials credentialsPEM = GenCredential.create(pemKeyPair.getPrivateKey().toString(16)); CnsService cnsService = new CnsService(web3j, credentialsPEM); // System.out.println(cnsService.registerCns(contractName, version, address, abi)); // assertNotNull(cnsService.registerCns(contractName, version, address, abi)); // 默认获取最新版本 // String res = cnsService.getAddressByContractNameAndVersion("contractNameAndVersion"); List<CnsInfo> list = new ArrayList<>(); list = cnsService.queryCnsByName(contractName); System.out.println(contractNameAndVersion); // System.out.println(cnsService.getAddressByContractNameAndVersion(contractName)); // assertNotNull(cnsService.getAddressByContractNameAndVersion(contractName)); // System.out.println(cnsService.queryCnsByName(contractName).size()); // System.out.println(cnsService.queryCnsByName(contractName).get(0).getAddress()); // System.out.println(cnsService.queryCnsByName(contractName).get(1).getAddress()); // assertTrue(cnsService.queryCnsByName(contractName).size() != 0); }
Example #13
Source File: RingSigPrecompiled.java From group-signature-client with GNU General Public License v3.0 | 5 votes |
protected RingSigPrecompiled( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); }
Example #14
Source File: ContractLifeCyclePrecompiled.java From web3sdk with Apache License 2.0 | 5 votes |
@Deprecated public static ContractLifeCyclePrecompiled load( String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { return new ContractLifeCyclePrecompiled( contractAddress, web3j, credentials, gasPrice, gasLimit); }
Example #15
Source File: Permission.java From web3sdk with Apache License 2.0 | 5 votes |
public static Permission load( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { return new Permission(contractAddress, web3j, credentials, contractGasProvider); }
Example #16
Source File: TestGroupSig.java From group-signature-client with GNU General Public License v3.0 | 5 votes |
public static TestGroupSig load( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { return new TestGroupSig(contractAddress, web3j, credentials, contractGasProvider); }
Example #17
Source File: DagTransfer.java From web3sdk with Apache License 2.0 | 5 votes |
@Deprecated protected DagTransfer( String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { super(getBinary(), contractAddress, web3j, credentials, gasPrice, gasLimit); }
Example #18
Source File: NewSolTest.java From web3sdk with Apache License 2.0 | 5 votes |
@Deprecated public static NewSolTest load( String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { return new NewSolTest(contractAddress, web3j, credentials, gasPrice, gasLimit); }
Example #19
Source File: TestRingSig.java From group-signature-client with GNU General Public License v3.0 | 5 votes |
@Deprecated public static TestRingSig load( String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { return new TestRingSig(contractAddress, web3j, credentials, gasPrice, gasLimit); }
Example #20
Source File: TestGroupSig.java From group-signature-client with GNU General Public License v3.0 | 5 votes |
@Deprecated protected TestGroupSig( String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); }
Example #21
Source File: TestRingSig.java From group-signature-client with GNU General Public License v3.0 | 5 votes |
public static TestRingSig load( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { return new TestRingSig(contractAddress, web3j, credentials, contractGasProvider); }
Example #22
Source File: CNS.java From web3sdk with Apache License 2.0 | 5 votes |
public static CNS load( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { return new CNS(contractAddress, web3j, credentials, contractGasProvider); }
Example #23
Source File: SystemConfig.java From web3sdk with Apache License 2.0 | 5 votes |
protected SystemConfig( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); }
Example #24
Source File: KeyPairUtils.java From WeBASE-Sign with Apache License 2.0 | 5 votes |
/** * get Credentials from privateKey by encrypt type * @param privateKey * @param encryptType 1: guomi, 0: standard * @return Credentials */ @Cacheable(cacheNames = "getCredentials") public Credentials create(String privateKey, int encryptType) { try { ECKeyPair keyPair = createKeyPairByType(privateKey, encryptType); if (keyPair == null) { return null; } Credentials credentials = Credentials.create(keyPair); return credentials; } catch (Exception e) { log.error("init credential from private key failed, error msg:" + e.getMessage()); return null; } }
Example #25
Source File: ChainGovernance.java From web3sdk with Apache License 2.0 | 5 votes |
protected ChainGovernance( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); }
Example #26
Source File: CRUD.java From web3sdk with Apache License 2.0 | 5 votes |
protected CRUD( String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); }
Example #27
Source File: Web3SDK2Wrapper.java From WeEvent with Apache License 2.0 | 5 votes |
public static String deployTopicControl(Web3j web3j, Credentials credentials, int timeout) throws BrokerException { log.info("begin deploy topic control"); try { // deploy Topic.sol in highest version(Web3SDK2Wrapper.nowVersion) RemoteCall<Topic> f1 = Topic.deploy(web3j, credentials, gasProvider); Topic topic = f1.sendAsync().get(timeout, TimeUnit.MILLISECONDS); log.info("topic contract address: {}", topic.getContractAddress()); if (topic.getContractAddress().equals(WeEventConstants.ADDRESS_EMPTY)) { log.error("contract address is empty after Topic.deploy(...)"); throw new BrokerException(ErrorCode.DEPLOY_CONTRACT_ERROR); } // deploy TopicController.sol in nowVersion RemoteCall<TopicController> f2 = TopicController.deploy(web3j, credentials, gasProvider, topic.getContractAddress()); TopicController topicController = f2.sendAsync().get(timeout, TimeUnit.MILLISECONDS); log.info("topic control contract address: {}", topicController.getContractAddress()); if (topicController.getContractAddress().equals(WeEventConstants.ADDRESS_EMPTY)) { log.error("contract address is empty after TopicController.deploy(...)"); throw new BrokerException(ErrorCode.DEPLOY_CONTRACT_ERROR); } log.info("deploy topic control success"); return topicController.getContractAddress(); } catch (InterruptedException | ExecutionException | TimeoutException e) { log.error("deploy contract failed", e); throw new BrokerException(ErrorCode.DEPLOY_CONTRACT_ERROR); } }
Example #28
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 #29
Source File: TableTest.java From web3sdk with Apache License 2.0 | 5 votes |
@Deprecated public static TableTest load( String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { return new TableTest(contractAddress, web3j, credentials, gasPrice, gasLimit); }
Example #30
Source File: ContractStatusService.java From web3sdk with Apache License 2.0 | 5 votes |
public ContractStatusService(Web3j web3j, Credentials credentials) { ContractGasProvider contractGasProvider = new StaticGasProvider(gasPrice, gasLimit); this.web3j = web3j; this.contractLifeCycle = ContractLifeCyclePrecompiled.load( ContractLifeCyclePrecompiledAddress, web3j, credentials, contractGasProvider); }