java.lang.Object
com.hedera.hashgraph.sdk.Executable<TokenAssociateTransaction,Transaction,TransactionResponse,TransactionResponse>
com.hedera.hashgraph.sdk.Transaction<TokenAssociateTransaction>
com.hedera.hashgraph.sdk.TokenAssociateTransaction
Associate a Hedera Token Service (HTS) token and an account.
An association MUST exist between an account and a token before that
account may transfer or receive that token.
If the identified account is not found, the transaction SHALL return `INVALID_ACCOUNT_ID`.
If the identified account has been deleted, the transaction SHALL return `ACCOUNT_DELETED`.
If any of the identified tokens is not found, the transaction SHALL return `INVALID_TOKEN_REF`.
If any of the identified tokens has been deleted, the transaction SHALL return `TOKEN_WAS_DELETED`.
If an association already exists for any of the identified tokens, the transaction SHALL return `TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT`.
The identified account MUST sign this transaction. ### Block Stream Effects None
If the identified account is not found, the transaction SHALL return `INVALID_ACCOUNT_ID`.
If the identified account has been deleted, the transaction SHALL return `ACCOUNT_DELETED`.
If any of the identified tokens is not found, the transaction SHALL return `INVALID_TOKEN_REF`.
If any of the identified tokens has been deleted, the transaction SHALL return `TOKEN_WAS_DELETED`.
If an association already exists for any of the identified tokens, the transaction SHALL return `TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT`.
The identified account MUST sign this transaction. ### Block Stream Effects None
-
Nested Class Summary
Nested classes/interfaces inherited from class com.hedera.hashgraph.sdk.Transaction
Transaction.SignableNodeTransactionBodyBytesNested classes/interfaces inherited from class com.hedera.hashgraph.sdk.Executable
Executable.GrpcRequest -
Field Summary
Fields inherited from class com.hedera.hashgraph.sdk.Transaction
customFeeLimits, DEFAULT_AUTO_RENEW_PERIOD, defaultMaxTransactionFee, DUMMY_ACCOUNT_ID, DUMMY_TRANSACTION_ID, frozenBodyBuilder, innerSignedTransactions, outerTransactions, publicKeys, regenerateTransactionId, signers, sigPairLists, sourceTransactionBody, transactionIdsFields inherited from class com.hedera.hashgraph.sdk.Executable
attemptedAllNodes, blockingUnaryCall, grpcDeadline, logger, maxAttempts, maxBackoff, minBackoff, nodeAccountIds, nodes, random, RST_STREAM -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.Constructor.Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) TokenAssociateTransactionBody.Builderbuild()Build the transaction body.Extract the account id.(package private) io.grpc.MethodDescriptor<Transaction, TransactionResponse> Called to direct the invocation of the query to the appropriate gRPC service.Extract the list of token id's.(package private) voidInitialize from the transaction body.(package private) voidonFreeze(TransactionBody.Builder bodyBuilder) Called inTransaction.freezeWith(Client)just before the transaction body is built.(package private) voidonScheduled(SchedulableTransactionBody.Builder scheduled) Called inTransaction.schedule()when converting transaction into a scheduled version.setAccountId(AccountId accountId) An account identifier.setTokenIds(List<TokenId> tokens) A list of token identifiers.(package private) voidvalidateChecksums(Client client) Methods inherited from class com.hedera.hashgraph.sdk.Transaction
addSignature, addSignature, batchify, buildAllTransactions, buildTransaction, doSchedule, estimateFee, freeze, freezeWith, fromBytes, fromScheduledTransaction, generateTransactionIds, getBatchKey, getDefaultMaxTransactionFee, getExecutionState, getHighVolume, getMaxTransactionFee, getRegenerateTransactionId, getRequiredChunks, getSignableNodeBodyBytesList, getSignatures, getSignaturesAtOffset, getTransactionBodySize, getTransactionHash, getTransactionHashPerNode, getTransactionId, getTransactionIdInternal, getTransactionMemo, getTransactionSize, getTransactionValidDuration, hash, isBatchedAndNotBatchTransaction, isFrozen, keyAlreadySigned, makeRequest, mapResponse, mapResponseStatus, onExecute, onExecuteAsync, regenerateTransactionId, requireNotFrozen, requireOneNodeAccountId, schedule, setBatchKey, setHighVolume, setMaxTransactionFee, setNodeAccountIds, setRegenerateTransactionId, setTransactionId, setTransactionMemo, setTransactionValidDuration, sign, signTransaction, signWith, signWithOperator, spawnBodyBuilder, toBytes, toString, wipeTransactionListsMethods inherited from class com.hedera.hashgraph.sdk.Executable
advanceRequest, checkNodeAccountIds, execute, execute, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, getGrpcRequest, getMaxAttempts, getMaxBackoff, getMaxRetry, getMinBackoff, getNodeAccountIds, getNodeForExecute, grpcDeadline, logTransaction, mergeFromClient, setGrpcDeadline, setLogger, setMaxAttempts, setMaxBackoff, setMaxRetry, setMinBackoff, setNodesFromNodeAccountIds, setRequestListener, setResponseListener, shouldRetryExceptionally
-
Constructor Details
-
TokenAssociateTransaction
public TokenAssociateTransaction()Constructor. -
TokenAssociateTransaction
TokenAssociateTransaction(LinkedHashMap<TransactionId, LinkedHashMap<AccountId, throws com.google.protobuf.InvalidProtocolBufferExceptionTransaction>> txs) Constructor.- Parameters:
txs- Compound list of transaction id's list of (AccountId, Transaction) records- Throws:
com.google.protobuf.InvalidProtocolBufferException- when there is an issue with the protobuf
-
TokenAssociateTransaction
TokenAssociateTransaction(TransactionBody txBody) Constructor.- Parameters:
txBody- protobuf TransactionBody
-
-
Method Details
-
getAccountId
Extract the account id.- Returns:
- the account id
-
setAccountId
An account identifier.The identified account SHALL be associated to each of the tokens identified in the `tokens` field.
This field is REQUIRED and MUST be a valid account identifier.
The identified account MUST exist in state.
The identified account MUST NOT be deleted.
The identified account MUST NOT be expired.- Parameters:
accountId- the account id- Returns:
this
-
getTokenIds
Extract the list of token id's.- Returns:
- the list of token id's
-
setTokenIds
A list of token identifiers.Each token identified in this list SHALL be separately associated with the account identified in the `account` field.
This list MUST NOT be empty. Each entry in this list MUST be a valid token identifier.
Each entry in this list MUST NOT be currently associated to the account identified in `account`.
Each entry in this list MUST NOT be expired.
Each entry in this list MUST NOT be deleted.- Parameters:
tokens- the list of token id's- Returns:
this
-
build
Build the transaction body.- Returns:
TokenAssociateTransactionBody
-
initFromTransactionBody
void initFromTransactionBody()Initialize from the transaction body. -
validateChecksums
- Specified by:
validateChecksumsin classTransaction<TokenAssociateTransaction>- Throws:
BadEntityIdException
-
getMethodDescriptor
io.grpc.MethodDescriptor<Transaction,TransactionResponse> getMethodDescriptor()Description copied from class:ExecutableCalled to direct the invocation of the query to the appropriate gRPC service.- Specified by:
getMethodDescriptorin classExecutable<TokenAssociateTransaction,Transaction, TransactionResponse, TransactionResponse>
-
onFreeze
Description copied from class:TransactionCalled inTransaction.freezeWith(Client)just before the transaction body is built. The intent is for the derived class to assign their data variant to the transaction body.- Specified by:
onFreezein classTransaction<TokenAssociateTransaction>
-
onScheduled
Description copied from class:TransactionCalled inTransaction.schedule()when converting transaction into a scheduled version.- Specified by:
onScheduledin classTransaction<TokenAssociateTransaction>
-