Search in sources :

Example 1 with ContractCreateFlow

use of com.hedera.hashgraph.sdk.ContractCreateFlow in project hedera-sdk-java by hashgraph.

the class ContractCreateFlowIntegrationTest method createContractWithFlow.

@Test
@DisplayName("Create contract with flow")
void createContractWithFlow() throws Throwable {
    var testEnv = new IntegrationTestEnv(1);
    var response = new ContractCreateFlow().setBytecode(SMART_CONTRACT_BYTECODE).setAdminKey(testEnv.operatorKey).setGas(100000).setConstructorParameters(new ContractFunctionParameters().addString("Hello from Hedera.")).setContractMemo("[e2e::ContractCreateFlow]").execute(testEnv.client);
    var contractId = Objects.requireNonNull(response.getReceipt(testEnv.client).contractId);
    var receipt = new ContractExecuteTransaction().setContractId(contractId).setGas(100000).setFunction("setMessage", new ContractFunctionParameters().addString("new message")).execute(testEnv.client).getReceipt(testEnv.client);
    assertThat(receipt.status).isEqualTo(Status.SUCCESS);
    new ContractDeleteTransaction().setTransferAccountId(testEnv.operatorId).setContractId(contractId).setTransferAccountId(testEnv.operatorId).execute(testEnv.client).getReceipt(testEnv.client);
    testEnv.close();
}
Also used : ContractDeleteTransaction(com.hedera.hashgraph.sdk.ContractDeleteTransaction) ContractExecuteTransaction(com.hedera.hashgraph.sdk.ContractExecuteTransaction) ContractFunctionParameters(com.hedera.hashgraph.sdk.ContractFunctionParameters) ContractCreateFlow(com.hedera.hashgraph.sdk.ContractCreateFlow) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

ContractCreateFlow (com.hedera.hashgraph.sdk.ContractCreateFlow)1 ContractDeleteTransaction (com.hedera.hashgraph.sdk.ContractDeleteTransaction)1 ContractExecuteTransaction (com.hedera.hashgraph.sdk.ContractExecuteTransaction)1 ContractFunctionParameters (com.hedera.hashgraph.sdk.ContractFunctionParameters)1 DisplayName (org.junit.jupiter.api.DisplayName)1 Test (org.junit.jupiter.api.Test)1