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);
}
Aggregations