org.web3j.tx.gas.ContractGasProvider Java Examples

The following examples show how to use org.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: ContractTest.java    From client-sdk-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testStaticGasProvider() throws IOException, TransactionException {
    ContractGasProvider gasProvider = new ContractGasProvider(BigInteger.TEN, BigInteger.ONE);
    TransactionManager txManager = mock(TransactionManager.class);
    when(txManager.executeTransaction(any(), any(), any(), any(), any()))
            .thenReturn(new TransactionReceipt());

    contract = new TestContract(ADDRESS, web3j, txManager, gasProvider);

    Function func = new Function("test",
            Arrays.<Type>asList(), Collections.<TypeReference<?>>emptyList());
    contract.executeTransaction(func);

    verify(txManager).executeTransaction(eq(BigInteger.TEN),
            eq(BigInteger.ONE), any(), any(), any());
}
 
Example #2
Source File: OnChainPrivacyGroupManagementProxy.java    From besu with Apache License 2.0 6 votes vote down vote up
public static RemoteCall<OnChainPrivacyGroupManagementProxy> deploy(
    Web3j web3j,
    TransactionManager transactionManager,
    ContractGasProvider contractGasProvider,
    String _implementation) {
  String encodedConstructor =
      FunctionEncoder.encodeConstructor(
          Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, _implementation)));
  return deployRemoteCall(
      OnChainPrivacyGroupManagementProxy.class,
      web3j,
      transactionManager,
      contractGasProvider,
      BINARY,
      encodedConstructor);
}
 
Example #3
Source File: CrossContractReader.java    From besu with Apache License 2.0 5 votes vote down vote up
protected CrossContractReader(
    final String contractAddress,
    final Web3j web3j,
    final Credentials credentials,
    final ContractGasProvider contractGasProvider) {
  super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #4
Source File: SimpleStorage.java    From ethsigner with Apache License 2.0 5 votes vote down vote up
protected SimpleStorage(
    String contractAddress,
    Web3j web3j,
    TransactionManager transactionManager,
    ContractGasProvider contractGasProvider) {
  super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #5
Source File: CrossContractReader.java    From besu with Apache License 2.0 5 votes vote down vote up
public static RemoteCall<CrossContractReader> deploy(
    final Web3j web3j,
    final TransactionManager transactionManager,
    final ContractGasProvider contractGasProvider) {
  return deployRemoteCall(
      CrossContractReader.class, web3j, transactionManager, contractGasProvider, BINARY, "");
}
 
Example #6
Source File: CrossContractReader.java    From besu with Apache License 2.0 5 votes vote down vote up
public static RemoteCall<CrossContractReader> deploy(
    final Web3j web3j,
    final Credentials credentials,
    final ContractGasProvider contractGasProvider) {
  return deployRemoteCall(
      CrossContractReader.class, web3j, credentials, contractGasProvider, BINARY, "");
}
 
Example #7
Source File: CrossContractReader.java    From besu with Apache License 2.0 5 votes vote down vote up
public static CrossContractReader load(
    final String contractAddress,
    final Web3j web3j,
    final TransactionManager transactionManager,
    final ContractGasProvider contractGasProvider) {
  return new CrossContractReader(contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #8
Source File: Contract.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
@Deprecated
protected Contract(String contractBinary, String contractAddress,
                   Web3j web3j, TransactionManager transactionManager,
                   BigInteger gasPrice, BigInteger gasLimit) {
    this(contractBinary, contractAddress, web3j, transactionManager,
            new ContractGasProvider(gasPrice, gasLimit));
}
 
Example #9
Source File: BaseContractTest.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
	credentials = Credentials.create(privateKey);
	address = credentials.getAddress();
	web3jService = new HttpService(nodeUrl);
	web3j = Web3j.build(web3jService);
	transactionManager = new RawTransactionManager(web3j, credentials, chainId);
	gasProvider = new ContractGasProvider(GAS_PRICE, GAS_LIMIT);
}
 
Example #10
Source File: DepositContract.java    From teku with Apache License 2.0 5 votes vote down vote up
protected DepositContract(
    String contractAddress,
    Web3j web3j,
    Credentials credentials,
    ContractGasProvider contractGasProvider) {
  super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #11
Source File: DepositContract.java    From teku with Apache License 2.0 5 votes vote down vote up
protected DepositContract(
    String contractAddress,
    Web3j web3j,
    TransactionManager transactionManager,
    ContractGasProvider contractGasProvider) {
  super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #12
Source File: DepositContract.java    From teku with Apache License 2.0 5 votes vote down vote up
public static DepositContract load(
    String contractAddress,
    Web3j web3j,
    Credentials credentials,
    ContractGasProvider contractGasProvider) {
  return new DepositContract(contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #13
Source File: DepositContract.java    From teku with Apache License 2.0 5 votes vote down vote up
public static DepositContract load(
    String contractAddress,
    Web3j web3j,
    TransactionManager transactionManager,
    ContractGasProvider contractGasProvider) {
  return new DepositContract(contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #14
Source File: HumanStandardToken.java    From web3j-quorum with Apache License 2.0 5 votes vote down vote up
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider, BigInteger _initialAmount, String _tokenName, BigInteger _decimalUnits, String _tokenSymbol) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(_initialAmount),
            new org.web3j.abi.datatypes.Utf8String(_tokenName),
            new org.web3j.abi.datatypes.generated.Uint8(_decimalUnits),
            new org.web3j.abi.datatypes.Utf8String(_tokenSymbol)));
    return deployRemoteCall(HumanStandardToken.class, web3j, credentials, contractGasProvider, BINARY, encodedConstructor);
}
 
Example #15
Source File: HumanStandardToken.java    From web3j-quorum with Apache License 2.0 5 votes vote down vote up
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider, BigInteger _initialAmount, String _tokenName, BigInteger _decimalUnits, String _tokenSymbol) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(_initialAmount),
            new org.web3j.abi.datatypes.Utf8String(_tokenName),
            new org.web3j.abi.datatypes.generated.Uint8(_decimalUnits),
            new org.web3j.abi.datatypes.Utf8String(_tokenSymbol)));
    return deployRemoteCall(HumanStandardToken.class, web3j, transactionManager, contractGasProvider, BINARY, encodedConstructor);
}
 
Example #16
Source File: BaseContract.java    From client-sdk-java with Apache License 2.0 5 votes vote down vote up
private GasProvider getDefaultGasProviderRemote(Function function) throws IOException {
    Transaction transaction = Transaction.createEthCallTransaction(transactionManager.getFromAddress(), contractAddress,  EncoderUtils.functionEncoder(function));
    BigInteger gasLimit = web3j.platonEstimateGas(transaction).send().getAmountUsed();
    BigInteger gasPrice = getDefaultGasPrice(function.getType());
    GasProvider gasProvider = new ContractGasProvider(gasPrice, gasLimit);
    return  gasProvider;
}
 
Example #17
Source File: CrossContractReader.java    From besu with Apache License 2.0 5 votes vote down vote up
protected CrossContractReader(
    final String contractAddress,
    final Web3j web3j,
    final TransactionManager transactionManager,
    final ContractGasProvider contractGasProvider) {
  super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #18
Source File: CrossContractReader.java    From besu with Apache License 2.0 5 votes vote down vote up
public static CrossContractReader load(
    final String contractAddress,
    final Web3j web3j,
    final Credentials credentials,
    final ContractGasProvider contractGasProvider) {
  return new CrossContractReader(contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #19
Source File: SimpleStorage.java    From besu with Apache License 2.0 5 votes vote down vote up
public static RemoteCall<SimpleStorage> deploy(
    final Web3j web3j,
    final TransactionManager transactionManager,
    final ContractGasProvider contractGasProvider) {
  return deployRemoteCall(
      SimpleStorage.class, web3j, transactionManager, contractGasProvider, BINARY, "");
}
 
Example #20
Source File: SimpleStorage.java    From besu with Apache License 2.0 5 votes vote down vote up
public static RemoteCall<SimpleStorage> deploy(
    final Web3j web3j,
    final Credentials credentials,
    final ContractGasProvider contractGasProvider) {
  return deployRemoteCall(
      SimpleStorage.class, web3j, credentials, contractGasProvider, BINARY, "");
}
 
Example #21
Source File: SimpleStorage.java    From besu with Apache License 2.0 5 votes vote down vote up
public static SimpleStorage load(
    final String contractAddress,
    final Web3j web3j,
    final TransactionManager transactionManager,
    final ContractGasProvider contractGasProvider) {
  return new SimpleStorage(contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #22
Source File: SimpleStorage.java    From besu with Apache License 2.0 5 votes vote down vote up
public static SimpleStorage load(
    final String contractAddress,
    final Web3j web3j,
    final Credentials credentials,
    final ContractGasProvider contractGasProvider) {
  return new SimpleStorage(contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #23
Source File: SimpleStorage.java    From besu with Apache License 2.0 5 votes vote down vote up
protected SimpleStorage(
    final String contractAddress,
    final Web3j web3j,
    final TransactionManager transactionManager,
    final ContractGasProvider contractGasProvider) {
  super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #24
Source File: SimpleStorage.java    From besu with Apache License 2.0 5 votes vote down vote up
protected SimpleStorage(
    final String contractAddress,
    final Web3j web3j,
    final Credentials credentials,
    final ContractGasProvider contractGasProvider) {
  super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #25
Source File: RevertReason.java    From besu with Apache License 2.0 5 votes vote down vote up
public static RemoteCall<RevertReason> deploy(
    final Web3j web3j,
    final TransactionManager transactionManager,
    final ContractGasProvider contractGasProvider) {
  return deployRemoteCall(
      RevertReason.class, web3j, transactionManager, contractGasProvider, BINARY, "");
}
 
Example #26
Source File: RevertReason.java    From besu with Apache License 2.0 5 votes vote down vote up
public static RemoteCall<RevertReason> deploy(
    final Web3j web3j,
    final Credentials credentials,
    final ContractGasProvider contractGasProvider) {
  return deployRemoteCall(
      RevertReason.class, web3j, credentials, contractGasProvider, BINARY, "");
}
 
Example #27
Source File: RevertReason.java    From besu with Apache License 2.0 5 votes vote down vote up
public static RevertReason load(
    final String contractAddress,
    final Web3j web3j,
    final TransactionManager transactionManager,
    final ContractGasProvider contractGasProvider) {
  return new RevertReason(contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #28
Source File: RevertReason.java    From besu with Apache License 2.0 5 votes vote down vote up
public static RevertReason load(
    final String contractAddress,
    final Web3j web3j,
    final Credentials credentials,
    final ContractGasProvider contractGasProvider) {
  return new RevertReason(contractAddress, web3j, credentials, contractGasProvider);
}
 
Example #29
Source File: RevertReason.java    From besu with Apache License 2.0 5 votes vote down vote up
protected RevertReason(
    final String contractAddress,
    final Web3j web3j,
    final TransactionManager transactionManager,
    final ContractGasProvider contractGasProvider) {
  super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}
 
Example #30
Source File: RevertReason.java    From besu with Apache License 2.0 5 votes vote down vote up
protected RevertReason(
    final String contractAddress,
    final Web3j web3j,
    final Credentials credentials,
    final ContractGasProvider contractGasProvider) {
  super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
}