org.fisco.bcos.web3j.tx.gas.ContractGasProvider Java Examples

The following examples show how to use org.fisco.bcos.web3j.tx.gas.ContractGasProvider. 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: TestRingSig.java    From group-signature-client with GNU General Public License v3.0 6 votes vote down vote up
public static RemoteCall<TestRingSig> deploy(
        Web3j web3j,
        Credentials credentials,
        ContractGasProvider contractGasProvider,
        String _sig,
        String _message,
        String _param_info) {
    String encodedConstructor =
            FunctionEncoder.encodeConstructor(
                    Arrays.<Type>asList(
                            new Utf8String(_sig),
                            new Utf8String(_message),
                            new Utf8String(_param_info)));
    return deployRemoteCall(
            TestRingSig.class,
            web3j,
            credentials,
            contractGasProvider,
            BINARY,
            encodedConstructor);
}
 
Example #2
Source File: TestGroupSig.java    From group-signature-client with GNU General Public License v3.0 6 votes vote down vote up
public static RemoteCall<TestGroupSig> deploy(
        Web3j web3j,
        Credentials credentials,
        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,
            credentials,
            contractGasProvider,
            BINARY,
            encodedConstructor);
}
 
Example #3
Source File: Ok.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
public static Ok load(
    String contractAddress,
    Web3j web3j,
    TransactionManager transactionManager,
    ContractGasProvider contractGasProvider) {
  return new Ok(contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #4
Source File: TestGroupSig.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
protected TestGroupSig(
        String contractAddress,
        Web3j web3j,
        Credentials credentials,
        ContractGasProvider contractGasProvider) {
    super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #5
Source File: GroupSigPrecompiled.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
protected GroupSigPrecompiled(
        String contractAddress,
        Web3j web3j,
        Credentials credentials,
        ContractGasProvider contractGasProvider) {
    super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #6
Source File: TestRingSig.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
public static TestRingSig load(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    return new TestRingSig(contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #7
Source File: GroupSigPrecompiled.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
public static GroupSigPrecompiled load(
        String contractAddress,
        Web3j web3j,
        Credentials credentials,
        ContractGasProvider contractGasProvider) {
    return new GroupSigPrecompiled(contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #8
Source File: GroupSigPrecompiled.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
public static GroupSigPrecompiled load(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    return new GroupSigPrecompiled(
            contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #9
Source File: RingSigPrecompiled.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
public static RingSigPrecompiled load(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    return new RingSigPrecompiled(
            contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #10
Source File: RingSigPrecompiled.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
public static RemoteCall<RingSigPrecompiled> deploy(
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    return deployRemoteCall(
            RingSigPrecompiled.class,
            web3j,
            transactionManager,
            contractGasProvider,
            BINARY,
            "");
}
 
Example #11
Source File: RingSigPrecompiled.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
protected RingSigPrecompiled(
        String contractAddress,
        Web3j web3j,
        Credentials credentials,
        ContractGasProvider contractGasProvider) {
    super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #12
Source File: GroupSigPrecompiled.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
public static RemoteCall<GroupSigPrecompiled> deploy(
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    return deployRemoteCall(
            GroupSigPrecompiled.class,
            web3j,
            transactionManager,
            contractGasProvider,
            BINARY,
            "");
}
 
Example #13
Source File: GroupSigPrecompiled.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
protected GroupSigPrecompiled(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #14
Source File: TransService.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
/**
 * send transaction locally
 */
public Object transHandleLocal(ReqTransHandle req) throws Exception {
    log.info("transHandle start. ReqTransHandle:[{}]", JsonUtils.toJSONString(req));

    // init contract params
    ContractOfTrans cof = new ContractOfTrans(req);
    // check param and build function
    ContractFunction contractFunction = buildContractFunction(cof);

    // address
    String address = cof.getContractAddress();

    // web3j
    Web3j web3j = web3ApiService.getWeb3j(cof.getGroupId());
    // get privateKey
    Credentials credentials = getCredentials(contractFunction.getConstant(), req.getUser());
    // contract load
    ContractGasProvider contractGasProvider =
            new StaticGasProvider(Constants.GAS_PRICE, Constants.GAS_LIMIT);
    CommonContract commonContract = CommonContract.load(address, web3j, credentials, contractGasProvider);

    // request
    Object result;
    Function function = new Function(cof.getFuncName(), contractFunction.getFinalInputs(),
            contractFunction.getFinalOutputs());
    if (contractFunction.getConstant()) {
        result = execCall(contractFunction.getOutputList(), function, commonContract);
    } else {
        result = execTransaction(function, commonContract);
    }

    log.info("transHandle end. name:{} func:{} result:{}", cof.getContractName(),
            cof.getFuncName(), JsonUtils.toJSONString(result));
    return result;
}
 
Example #15
Source File: ContractAbiUtilTest.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetFunctionFromAbi() throws Exception {
    String contractName = "hello";
    String version = "1.0";
    List<AbiDefinition> abiList = ContractAbiUtil.loadContractDefinition(new File("src/test/resources/solidity/Ok.abi"));
    ContractAbiUtil.setContractWithAbi(contractName, version, abiList, false);
    List<ContractAbiUtil.VersionEvent> versionEvents = contractEventMap.get("hello");
    String funcName = "trans";
    List<String> funcInputTypes = versionEvents.get(0).getFuncInputs().get(funcName);
    ArrayList a = new ArrayList();
    a.add("123");
    List<Object> params = a;
    List<Type> finalInputs = AbiUtil.inputFormat(funcInputTypes, params);
    List<String> funOutputTypes = ContractAbiUtil.getFuncOutputType(contractName, "trans", version);
    List<TypeReference<?>> finalOutputs = outputFormat(funOutputTypes);
    Function function = new Function(funcName, finalInputs, finalOutputs);

    Ok okDemo = Ok.deploy(web3j, credentials, gasPrice, gasLimit).send();
    ContractGasProvider contractGasProvider = new StaticGasProvider(Constants.GAS_PRICE, Constants.GAS_LIMIT);
    CommonContract commonContract = CommonContract.load(okDemo.getContractAddress(), web3j, credentials, contractGasProvider);

    TransactionReceipt t  = TransService.execTransaction(function, commonContract);
    System.out.println("***********************");
    System.out.println(t);

    //invoke get function
    String funcName1 = "get";
    List<String> funcInputTypes1 = versionEvents.get(0).getFuncInputs().get(funcName1);
    ArrayList a1 = new ArrayList();
    List<Object> params1 = a1;
    List<Type> finalInputs1 = AbiUtil.inputFormat(funcInputTypes1, params1);

    List<String> funOutputTypes1 = ContractAbiUtil.getFuncOutputType(contractName, funcName1, version);
    List<TypeReference<?>> finalOutputs1 = outputFormat(funOutputTypes1);
    Function function1 = new Function(funcName1, finalInputs1, finalOutputs1);
    Object o  = TransService.execCall(funOutputTypes1, function1, commonContract);
}
 
Example #16
Source File: Ok.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
public static Ok load(
    String contractAddress,
    Web3j web3j,
    Credentials credentials,
    ContractGasProvider contractGasProvider) {
  return new Ok(contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #17
Source File: Ok.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
protected Ok(
    String contractAddress,
    Web3j web3j,
    TransactionManager transactionManager,
    ContractGasProvider contractGasProvider) {
  super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #18
Source File: Ok.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
protected Ok(
    String contractAddress,
    Web3j web3j,
    Credentials credentials,
    ContractGasProvider contractGasProvider) {
  super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #19
Source File: TestRingSig.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
public static TestRingSig load(
        String contractAddress,
        Web3j web3j,
        Credentials credentials,
        ContractGasProvider contractGasProvider) {
    return new TestRingSig(contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #20
Source File: TestRingSig.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
protected TestRingSig(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #21
Source File: TestGroupSig.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
public static TestGroupSig load(
        String contractAddress,
        Web3j web3j,
        Credentials credentials,
        ContractGasProvider contractGasProvider) {
    return new TestGroupSig(contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #22
Source File: Evidence.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
public static RemoteCall<Evidence> deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider, 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, contractGasProvider, BINARY, encodedConstructor);
}
 
Example #23
Source File: TestGroupSig.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
public static TestGroupSig load(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    return new TestGroupSig(contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #24
Source File: RingSigPrecompiled.java    From group-signature-client with GNU General Public License v3.0 5 votes vote down vote up
protected RingSigPrecompiled(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #25
Source File: Topic.java    From WeEvent with Apache License 2.0 4 votes vote down vote up
public static Topic load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
    return new Topic(contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #26
Source File: TopicController.java    From WeEvent with Apache License 2.0 4 votes vote down vote up
public static RemoteCall<TopicController> deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider, String topicAddress) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.fisco.bcos.web3j.abi.datatypes.Address(topicAddress)));
    return deployRemoteCall(TopicController.class, web3j, credentials, contractGasProvider, getBinary(), encodedConstructor);
}
 
Example #27
Source File: Topic.java    From WeEvent with Apache License 2.0 4 votes vote down vote up
protected Topic(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
    super(getBinary(), contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #28
Source File: Topic.java    From WeEvent with Apache License 2.0 4 votes vote down vote up
public static Topic load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
    return new Topic(contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #29
Source File: Topic.java    From WeEvent with Apache License 2.0 4 votes vote down vote up
public static RemoteCall<Topic> deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
    return deployRemoteCall(Topic.class, web3j, credentials, contractGasProvider, getBinary(), "");
}
 
Example #30
Source File: HelloWorldGM.java    From WeBASE-Front with Apache License 2.0 4 votes vote down vote up
public static RemoteCall<HelloWorldGM> deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
    return deployRemoteCall(HelloWorldGM.class, web3j, transactionManager, contractGasProvider, BINARY, "");
}