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

The following examples show how to use org.fisco.bcos.web3j.tx.gas.ContractGasProvider. These examples are extracted from open source projects. 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
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
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 Project: WeBASE-Front   Source File: TransService.java    License: 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 4
protected RingSigPrecompiled(
        String contractAddress,
        Web3j web3j,
        Credentials credentials,
        ContractGasProvider contractGasProvider) {
    super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
}
 
Example 5
public static RingSigPrecompiled load(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    return new RingSigPrecompiled(
            contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example 6
protected TestGroupSig(
        String contractAddress,
        Web3j web3j,
        Credentials credentials,
        ContractGasProvider contractGasProvider) {
    super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
}
 
Example 7
public static TestGroupSig load(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    return new TestGroupSig(contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example 8
Source Project: WeBASE-Front   Source File: Evidence.java    License: 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 9
Source Project: WeBASE-Front   Source File: Ok.java    License: 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 10
Source Project: WeBASE-Front   Source File: Ok.java    License: 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 11
Source Project: WeBASE-Front   Source File: Ok.java    License: 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 12
Source Project: WeBASE-Front   Source File: Ok.java    License: 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 13
protected TestRingSig(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example 14
Source Project: WeBASE-Front   Source File: ContractAbiUtilTest.java    License: 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 15
public static TestRingSig load(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    return new TestRingSig(contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example 16
protected RingSigPrecompiled(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example 17
public static TestRingSig load(
        String contractAddress,
        Web3j web3j,
        Credentials credentials,
        ContractGasProvider contractGasProvider) {
    return new TestRingSig(contractAddress, web3j, credentials, contractGasProvider);
}
 
Example 18
public static TestGroupSig load(
        String contractAddress,
        Web3j web3j,
        Credentials credentials,
        ContractGasProvider contractGasProvider) {
    return new TestGroupSig(contractAddress, web3j, credentials, contractGasProvider);
}
 
Example 19
protected GroupSigPrecompiled(
        String contractAddress,
        Web3j web3j,
        Credentials credentials,
        ContractGasProvider contractGasProvider) {
    super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
}
 
Example 20
protected GroupSigPrecompiled(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example 21
public static GroupSigPrecompiled load(
        String contractAddress,
        Web3j web3j,
        Credentials credentials,
        ContractGasProvider contractGasProvider) {
    return new GroupSigPrecompiled(contractAddress, web3j, credentials, contractGasProvider);
}
 
Example 22
public static GroupSigPrecompiled load(
        String contractAddress,
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    return new GroupSigPrecompiled(
            contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example 23
public static RemoteCall<RingSigPrecompiled> deploy(
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    return deployRemoteCall(
            RingSigPrecompiled.class,
            web3j,
            transactionManager,
            contractGasProvider,
            BINARY,
            "");
}
 
Example 24
public static RemoteCall<GroupSigPrecompiled> deploy(
        Web3j web3j,
        TransactionManager transactionManager,
        ContractGasProvider contractGasProvider) {
    return deployRemoteCall(
            GroupSigPrecompiled.class,
            web3j,
            transactionManager,
            contractGasProvider,
            BINARY,
            "");
}
 
Example 25
Source Project: WeBASE-Front   Source File: CommonContract.java    License: Apache License 2.0 4 votes vote down vote up
protected CommonContract(String contractAddress, Web3j web3j, Credentials credentials,
        ContractGasProvider gasProvider) {
    super("", contractAddress, web3j, credentials, gasProvider);
}
 
Example 26
Source Project: WeBASE-Front   Source File: CommonContract.java    License: Apache License 2.0 4 votes vote down vote up
public static CommonContract loadByName(String contractName, Web3j web3j,
        Credentials credentials, ContractGasProvider gasProvider) {
    return new CommonContract(contractName, web3j, credentials, gasProvider);
}
 
Example 27
Source Project: WeBASE-Front   Source File: EvidenceSignersData.java    License: Apache License 2.0 4 votes vote down vote up
protected EvidenceSignersData(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
    super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example 28
Source Project: WeBASE-Front   Source File: EvidenceSignersData.java    License: Apache License 2.0 4 votes vote down vote up
public static EvidenceSignersData load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
    return new EvidenceSignersData(contractAddress, web3j, credentials, contractGasProvider);
}
 
Example 29
Source Project: WeBASE-Front   Source File: EvidenceSignersData.java    License: Apache License 2.0 4 votes vote down vote up
public static EvidenceSignersData load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
    return new EvidenceSignersData(contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example 30
Source Project: WeBASE-Front   Source File: EvidenceSignersData.java    License: Apache License 2.0 4 votes vote down vote up
public static RemoteCall<EvidenceSignersData> deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider, List<String> evidenceSigners) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(evidenceSigners.isEmpty()?org.fisco.bcos.web3j.abi.datatypes.DynamicArray.empty("address[]"):new org.fisco.bcos.web3j.abi.datatypes.DynamicArray<org.fisco.bcos.web3j.abi.datatypes.Address>(
                    org.fisco.bcos.web3j.abi.Utils.typeMap(evidenceSigners, org.fisco.bcos.web3j.abi.datatypes.Address.class))));
    return deployRemoteCall(EvidenceSignersData.class, web3j, credentials, contractGasProvider, BINARY, encodedConstructor);
}