Class Address

java.lang.Object
org.stellar.sdk.Address

public class Address extends Object
Represents a single address in the Stellar network. An address can represent an account, contract, muxed account, claimable balance, liquidity pool, or muxed contract.
  • Constructor Details

    • Address

      public Address(String address)
      Creates a new Address from a Stellar public key (G...), contract ID (C...), med25519 public key (M...), liquidity pool ID (L...), claimable balance ID (B...), or muxed contract address (W...).
      Parameters:
      address - the StrKey encoded format of Stellar address.
  • Method Details

    • fromAccount

      public static Address fromAccount(byte[] accountId)
      Creates a new Address from a Stellar public key.
      Parameters:
      accountId - the byte array of the Stellar public key (G...).
      Returns:
      a new Address object from the given Stellar public key.
    • fromContract

      public static Address fromContract(byte[] contractId)
      Creates a new Address from a Stellar Contract ID.
      Parameters:
      contractId - the byte array of the Stellar Contract ID.
      Returns:
      a new Address object from the given Stellar Contract ID.
    • fromMuxedAccount

      public static Address fromMuxedAccount(byte[] muxedAccountId)
      Creates a new Address from a Stellar med25519 public key.
      Parameters:
      muxedAccountId - the byte array of the Stellar med25519 public key (M...).
      Returns:
      a new Address object from the given Stellar med25519 public key.
    • fromClaimableBalance

      public static Address fromClaimableBalance(byte[] claimableBalanceId)
      Creates a new Address from a Stellar Claimable Balance ID.
      Parameters:
      claimableBalanceId - the byte array of the Stellar Claimable Balance ID (B...).
      Returns:
      a new Address object from the given Stellar Claimable Balance ID.
    • fromLiquidityPool

      public static Address fromLiquidityPool(byte[] liquidityPoolId)
      Creates a new Address from a Stellar Liquidity Pool ID.
      Parameters:
      liquidityPoolId - the byte array of the Stellar Liquidity Pool ID (L...).
      Returns:
      a new Address object from the given Stellar Liquidity Pool ID.
    • fromMuxedContract

      public static Address fromMuxedContract(byte[] muxedContract)
      Creates a new Address from a Stellar muxed contract address.
      Parameters:
      muxedContract - the byte array of the Stellar muxed contract address (W...), the 32-byte contract ID followed by the 8-byte big-endian ID.
      Returns:
      a new Address object from the given Stellar muxed contract address.
    • fromSCAddress

      public static Address fromSCAddress(SCAddress scAddress)
      Creates a new Address from a SCAddress XDR object.
      Parameters:
      scAddress - the SCAddress object to convert
      Returns:
      a new Address object from the given XDR object
    • fromSCVal

      public static Address fromSCVal(SCVal scVal)
      Creates a new Address from a SCVal XDR object.
      Parameters:
      scVal - the SCVal object to convert
      Returns:
      a new Address object from the given XDR object
    • toSCAddress

      public SCAddress toSCAddress()
      Converts this object to its SCAddress XDR object representation.
      Returns:
      a new SCAddress object from this object
    • toSCVal

      public SCVal toSCVal()
      Converts this object to its SCVal XDR object representation.
      Returns:
      a new SCVal object from this object
    • getBytes

      public byte[] getBytes()
      Returns the raw bytes of this address, as encoded in its StrKey:
      • ACCOUNT: the 32-byte ed25519 public key
      • CONTRACT: the 32-byte contract ID
      • MUXED_ACCOUNT: the 32-byte ed25519 public key followed by the 8-byte big-endian ID
      • CLAIMABLE_BALANCE: the 1-byte claimable balance type (0) followed by the 32-byte hash
      • LIQUIDITY_POOL: the 32-byte liquidity pool ID
      • MUXED_CONTRACT: the 32-byte contract ID followed by the 8-byte big-endian ID
      Returns:
      the raw bytes of this address
    • getAddressType

      public Address.AddressType getAddressType()
      Returns the type of this address.
      Returns:
      the type of this address.
    • getEncodedAddress

      public String getEncodedAddress()
      Gets the encoded string representation of this address.
      Returns:
      The StrKey-encoded representation of this address
      Throws:
      IllegalArgumentException - if the address type is unknown
    • toString

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object