Search in sources :

Example 26 with TopicCreateTransaction

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

the class CreateTopicExample method main.

public static void main(String[] args) throws TimeoutException, PrecheckStatusException, ReceiptStatusException {
    Client client = Client.forName(HEDERA_NETWORK);
    // Defaults the operator account ID and key such that all generated transactions will be paid for
    // by this account and be signed by this key
    client.setOperator(OPERATOR_ID, OPERATOR_KEY);
    // Create three accounts, Alice, Bob, and Charlie.  Alice will be the treasury for our example token.
    // Fees only apply in transactions not involving the treasury, so we need two other accounts.
    TransactionResponse createResponse = new TopicCreateTransaction().execute(client);
    TransactionReceipt createReceipt = createResponse.getReceipt(client);
    System.out.println("topic id = " + createReceipt.topicId);
    TransactionResponse sendResponse = new TopicMessageSubmitTransaction().setTopicId(createReceipt.topicId).setMessage("Hello World").execute(client);
    TransactionReceipt sendReceipt = sendResponse.getReceipt(client);
    System.out.println("topic sequence number = " + sendReceipt.topicSequenceNumber);
}
Also used : TopicCreateTransaction(com.hedera.hashgraph.sdk.TopicCreateTransaction) TransactionResponse(com.hedera.hashgraph.sdk.TransactionResponse) TransactionReceipt(com.hedera.hashgraph.sdk.TransactionReceipt) Client(com.hedera.hashgraph.sdk.Client) TopicMessageSubmitTransaction(com.hedera.hashgraph.sdk.TopicMessageSubmitTransaction)

Aggregations

TopicCreateTransaction (com.hedera.hashgraph.sdk.TopicCreateTransaction)26 Test (org.junit.jupiter.api.Test)19 DisplayName (org.junit.jupiter.api.DisplayName)17 TopicDeleteTransaction (com.hedera.hashgraph.sdk.TopicDeleteTransaction)15 TopicInfoQuery (com.hedera.hashgraph.sdk.TopicInfoQuery)10 TopicMessageSubmitTransaction (com.hedera.hashgraph.sdk.TopicMessageSubmitTransaction)10 Var (com.google.errorprone.annotations.Var)4 TopicMessageQuery (com.hedera.hashgraph.sdk.TopicMessageQuery)4 TransactionResponse (com.hedera.hashgraph.sdk.TransactionResponse)4 Client (com.hedera.hashgraph.sdk.Client)3 PublicKey (com.hedera.hashgraph.sdk.PublicKey)3 TopicId (com.hedera.hashgraph.sdk.TopicId)3 Hbar (com.hedera.hashgraph.sdk.Hbar)2 KeyList (com.hedera.hashgraph.sdk.KeyList)2 TransactionReceipt (com.hedera.hashgraph.sdk.TransactionReceipt)2 AbstractTransactionSupplierTest (com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)2 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)1 MaxQueryPaymentExceededException (com.hedera.hashgraph.sdk.MaxQueryPaymentExceededException)1 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)1 ScheduleInfoQuery (com.hedera.hashgraph.sdk.ScheduleInfoQuery)1