Search in sources :

Example 16 with TokenCreateTransaction

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

the class TokenCreateIntegrationTest method cannotCreateTokenWhenTokenNameIsNotSet.

@Test
@DisplayName("Cannot create token when token name is not set")
void cannotCreateTokenWhenTokenNameIsNotSet() throws Exception {
    var testEnv = new IntegrationTestEnv(1).useThrowawayAccount();
    assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
        new TokenCreateTransaction().setTokenSymbol("F").setTreasuryAccountId(testEnv.operatorId).execute(testEnv.client).getReceipt(testEnv.client);
    }).withMessageContaining(Status.MISSING_TOKEN_NAME.toString());
    testEnv.close();
}
Also used : TokenCreateTransaction(com.hedera.hashgraph.sdk.TokenCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 17 with TokenCreateTransaction

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

the class TokenCreateIntegrationTest method canCreateTokenWithOperatorAsAllKeys.

@Test
@DisplayName("Can create token with operator as all keys")
void canCreateTokenWithOperatorAsAllKeys() throws Exception {
    var testEnv = new IntegrationTestEnv(1).useThrowawayAccount();
    var response = new TokenCreateTransaction().setTokenName("ffff").setTokenSymbol("F").setDecimals(3).setInitialSupply(1000000).setTreasuryAccountId(testEnv.operatorId).setAdminKey(testEnv.operatorKey).setFreezeKey(testEnv.operatorKey).setWipeKey(testEnv.operatorKey).setKycKey(testEnv.operatorKey).setSupplyKey(testEnv.operatorKey).setFeeScheduleKey(testEnv.operatorKey).setFreezeDefault(false).execute(testEnv.client);
    var tokenId = Objects.requireNonNull(response.getReceipt(testEnv.client).tokenId);
    testEnv.close(tokenId);
}
Also used : TokenCreateTransaction(com.hedera.hashgraph.sdk.TokenCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 18 with TokenCreateTransaction

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

the class TokenDeleteIntegrationTest method canDeleteToken.

@Test
@DisplayName("Can delete token")
void canDeleteToken() throws Exception {
    var testEnv = new IntegrationTestEnv(1).useThrowawayAccount();
    var response = new TokenCreateTransaction().setTokenName("ffff").setTokenSymbol("F").setDecimals(3).setInitialSupply(1000000).setTreasuryAccountId(testEnv.operatorId).setAdminKey(testEnv.operatorKey).setFreezeKey(testEnv.operatorKey).setWipeKey(testEnv.operatorKey).setKycKey(testEnv.operatorKey).setSupplyKey(testEnv.operatorKey).setFreezeDefault(false).execute(testEnv.client);
    var tokenId = Objects.requireNonNull(response.getReceipt(testEnv.client).tokenId);
    new TokenDeleteTransaction().setTokenId(tokenId).execute(testEnv.client).getReceipt(testEnv.client);
    testEnv.close();
}
Also used : TokenDeleteTransaction(com.hedera.hashgraph.sdk.TokenDeleteTransaction) TokenCreateTransaction(com.hedera.hashgraph.sdk.TokenCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 19 with TokenCreateTransaction

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

the class TokenDeleteIntegrationTest method canDeleteTokenWithOnlyAdminKeySet.

@Test
@DisplayName("Can delete token with only admin key set")
void canDeleteTokenWithOnlyAdminKeySet() throws Exception {
    var testEnv = new IntegrationTestEnv(1).useThrowawayAccount();
    var response = new TokenCreateTransaction().setTokenName("ffff").setTokenSymbol("F").setTreasuryAccountId(testEnv.operatorId).setAdminKey(testEnv.operatorKey).execute(testEnv.client);
    var tokenId = Objects.requireNonNull(response.getReceipt(testEnv.client).tokenId);
    testEnv.close(tokenId);
}
Also used : TokenCreateTransaction(com.hedera.hashgraph.sdk.TokenCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 20 with TokenCreateTransaction

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

the class TokenMintIntegrationTest method canMintTokens.

@Test
@DisplayName("Can mint tokens")
void canMintTokens() throws Exception {
    var testEnv = new IntegrationTestEnv(1).useThrowawayAccount();
    var tokenId = Objects.requireNonNull(new TokenCreateTransaction().setTokenName("ffff").setTokenSymbol("F").setDecimals(3).setInitialSupply(1000000).setTreasuryAccountId(testEnv.operatorId).setAdminKey(testEnv.operatorKey).setFreezeKey(testEnv.operatorKey).setWipeKey(testEnv.operatorKey).setKycKey(testEnv.operatorKey).setSupplyKey(testEnv.operatorKey).setFreezeDefault(false).execute(testEnv.client).getReceipt(testEnv.client).tokenId);
    var receipt = new TokenMintTransaction().setAmount(10).setTokenId(tokenId).execute(testEnv.client).getReceipt(testEnv.client);
    assertThat(receipt.totalSupply).isEqualTo(1000000 + 10);
    testEnv.close(tokenId);
}
Also used : TokenMintTransaction(com.hedera.hashgraph.sdk.TokenMintTransaction) TokenCreateTransaction(com.hedera.hashgraph.sdk.TokenCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

TokenCreateTransaction (com.hedera.hashgraph.sdk.TokenCreateTransaction)70 Test (org.junit.jupiter.api.Test)64 DisplayName (org.junit.jupiter.api.DisplayName)61 Hbar (com.hedera.hashgraph.sdk.Hbar)34 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)29 TokenAssociateTransaction (com.hedera.hashgraph.sdk.TokenAssociateTransaction)21 TokenMintTransaction (com.hedera.hashgraph.sdk.TokenMintTransaction)15 TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)14 TokenGrantKycTransaction (com.hedera.hashgraph.sdk.TokenGrantKycTransaction)11 TokenInfoQuery (com.hedera.hashgraph.sdk.TokenInfoQuery)10 TokenWipeTransaction (com.hedera.hashgraph.sdk.TokenWipeTransaction)8 CustomFixedFee (com.hedera.hashgraph.sdk.CustomFixedFee)7 ArrayList (java.util.ArrayList)7 Var (com.google.errorprone.annotations.Var)6 TokenDeleteTransaction (com.hedera.hashgraph.sdk.TokenDeleteTransaction)6 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)5 PublicKey (com.hedera.hashgraph.sdk.PublicKey)5 CustomFractionalFee (com.hedera.hashgraph.sdk.CustomFractionalFee)4 TokenId (com.hedera.hashgraph.sdk.TokenId)4 TokenNftInfoQuery (com.hedera.hashgraph.sdk.TokenNftInfoQuery)4