Class TokenAssociation

java.lang.Object
com.hedera.hashgraph.sdk.TokenAssociation

public class TokenAssociation extends Object
Associates the provided Hedera account with the provided Hedera token(s). Hedera accounts must be associated with a fungible or non-fungible token first before you can transfer tokens to that account. In the case of NON_FUNGIBLE Type, once an account is associated, it can hold any number of NFTs (serial numbers) of that token type. The Hedera account that is being associated with a token is required to sign the transaction. See Hedera Documentation
  • Field Details

    • tokenId

      public final TokenId tokenId
      The token involved in the association
    • accountId

      public final AccountId accountId
      The account involved in the association
  • Constructor Details

    • TokenAssociation

      TokenAssociation(TokenId tokenId, AccountId accountId)
      Constructor.
      Parameters:
      tokenId - the token id
      accountId - the account id
  • Method Details

    • fromProtobuf

      static TokenAssociation fromProtobuf(TokenAssociation tokenAssociation)
      Create a token association from a protobuf.
      Parameters:
      tokenAssociation - the protobuf
      Returns:
      the new token association
    • fromBytes

      public static TokenAssociation fromBytes(byte[] bytes) throws com.google.protobuf.InvalidProtocolBufferException
      Create a token association from a byte array.
      Parameters:
      bytes - the byte array
      Returns:
      the new token association
      Throws:
      com.google.protobuf.InvalidProtocolBufferException - when there is an issue with the protobuf
    • toProtobuf

      TokenAssociation toProtobuf()
      Create the protobuf.
      Returns:
      the protobuf representation
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toBytes

      public byte[] toBytes()
      Create the byte array.
      Returns:
      the byte array representation