Search in sources :

Example 1 with Provenance

use of org.eclipse.winery.accountability.blockchain.ethereum.generated.Provenance in project winery by eclipse.

the class SmartContractProvider method buildProvenanceSmartContract.

public static Provenance buildProvenanceSmartContract(final Web3j web3j, final Credentials credentials, String smartContractAddress) throws BlockchainException {
    final Provenance contract = Provenance.load(smartContractAddress, web3j, credentials, DefaultGasProvider.GAS_PRICE, DefaultGasProvider.GAS_LIMIT);
    validateSmartContract(contract, smartContractAddress);
    return contract;
}
Also used : Provenance(org.eclipse.winery.accountability.blockchain.ethereum.generated.Provenance)

Example 2 with Provenance

use of org.eclipse.winery.accountability.blockchain.ethereum.generated.Provenance in project winery by eclipse.

the class ContractDeployer method deployProvenance.

/**
 * Deploys the provenance smart contract
 *
 * @return Address of the smart Contract that was deployed
 */
public String deployProvenance() throws Exception {
    final StaticGasProvider provider = new DefaultGasProvider();
    Provenance provenance = Provenance.deploy(web3j, credentials, provider).send();
    LOGGER.debug("Provenance SC Address: " + provenance.getContractAddress());
    return provenance.getContractAddress();
}
Also used : StaticGasProvider(org.web3j.tx.gas.StaticGasProvider) Provenance(org.eclipse.winery.accountability.blockchain.ethereum.generated.Provenance) DefaultGasProvider(org.web3j.tx.gas.DefaultGasProvider)

Example 3 with Provenance

use of org.eclipse.winery.accountability.blockchain.ethereum.generated.Provenance in project winery by eclipse.

the class ProvenanceSmartContractWrapper method saveState.

public CompletableFuture<String> saveState(final String identifier, final String state) {
    LocalDateTime start = LocalDateTime.now();
    byte[] compressed = CompressionUtils.compress(state.getBytes());
    LOGGER.debug("Compressing fingerprint lasted {}", Duration.between(LocalDateTime.now(), start).toString());
    return ((Provenance) contract).addResourceVersion(identifier, compressed).sendAsync().thenApply(TransactionReceipt::getTransactionHash);
}
Also used : LocalDateTime(java.time.LocalDateTime) Provenance(org.eclipse.winery.accountability.blockchain.ethereum.generated.Provenance) TransactionReceipt(org.web3j.protocol.core.methods.response.TransactionReceipt)

Aggregations

Provenance (org.eclipse.winery.accountability.blockchain.ethereum.generated.Provenance)3 LocalDateTime (java.time.LocalDateTime)1 TransactionReceipt (org.web3j.protocol.core.methods.response.TransactionReceipt)1 DefaultGasProvider (org.web3j.tx.gas.DefaultGasProvider)1 StaticGasProvider (org.web3j.tx.gas.StaticGasProvider)1