Class ABIDecoder


  • public class ABIDecoder
    extends java.lang.Object
    Utility class for AVM ABI decoding.

    Creates a stateful decoder object, on top of input transaction data, for converting this binary stream into a stream of primitives or high-level objects.

    This is typically used for decoding arguments passed into a contract or a value returned from one.

    • Constructor Detail

      • ABIDecoder

        public ABIDecoder​(byte[] data)
        Creates a new decoder, initialized to point to the beginning of the input data.
        Parameters:
        data - Subsequent calls to functions like decodeAByte() will read from this byte array.
    • Method Detail

      • decodeMethodName

        public java.lang.String decodeMethodName()
        Decode a method name from the data field. If the decoding fails, we assume no methodName was supplied, such as the balance transfer case.

        Note that this is the same as decodeOneString() except that it handles failure differently, as is required by some cases covered by the ABI Compiler's generated code. In general, calling that other method is more appropriate.

        Returns:
        the decoded method name (null if there was no data to decode).
      • decodeOneByte

        public byte decodeOneByte()
        Decode a byte from the data field.
        Returns:
        the decoded byte.
      • decodeOneBoolean

        public boolean decodeOneBoolean()
        Decode a boolean from the data field.
        Returns:
        the decoded boolean.
      • decodeOneCharacter

        public char decodeOneCharacter()
        Decode a char from the data field.
        Returns:
        the decoded char.
      • decodeOneShort

        public short decodeOneShort()
        Decode a short from the data field.
        Returns:
        the decoded short.
      • decodeOneInteger

        public int decodeOneInteger()
        Decode an integer from the data field.
        Returns:
        the decoded integer.
      • decodeOneLong

        public long decodeOneLong()
        Decode a long from the data field.
        Returns:
        the decoded long.
      • decodeOneFloat

        public float decodeOneFloat()
        Decode a float from the data field.
        Returns:
        the decoded float.
      • decodeOneDouble

        public double decodeOneDouble()
        Decode a double from the data field.
        Returns:
        the decoded double.
      • decodeOneByteArray

        public byte[] decodeOneByteArray()
        Decode a byte array from the data field.
        Returns:
        the decoded byte array.
      • decodeOneBooleanArray

        public boolean[] decodeOneBooleanArray()
        Decode a boolean array from the data field.
        Returns:
        the decoded boolean array.
      • decodeOneCharacterArray

        public char[] decodeOneCharacterArray()
        Decode a character array from the data field.
        Returns:
        the decoded character array.
      • decodeOneShortArray

        public short[] decodeOneShortArray()
        Decode a short array from the data field.
        Returns:
        the decoded short array.
      • decodeOneIntegerArray

        public int[] decodeOneIntegerArray()
        Decode an integer array from the data field.
        Returns:
        the decoded integer array.
      • decodeOneLongArray

        public long[] decodeOneLongArray()
        Decode a long array from the data field.
        Returns:
        the decoded long array.
      • decodeOneFloatArray

        public float[] decodeOneFloatArray()
        Decode a float array from the data field.
        Returns:
        the decoded float array.
      • decodeOneDoubleArray

        public double[] decodeOneDoubleArray()
        Decode a double array from the data field.
        Returns:
        the decoded double array.
      • decodeOneString

        public java.lang.String decodeOneString()
        Decode a string from the data field.
        Returns:
        the decoded string.
      • decodeOneAddress

        public Address decodeOneAddress()
        Decode an address from the data field.
        Returns:
        the decoded address.
      • decodeOneBigInteger

        public java.math.BigInteger decodeOneBigInteger()
        Decode an BigInteger from the data field.
        Returns:
        the decoded BigInteger.
      • decodeOne2DByteArray

        public byte[][] decodeOne2DByteArray()
        Decode a 2D byte array from the data field.
        Returns:
        the decoded 2D byte array.
      • decodeOne2DBooleanArray

        public boolean[][] decodeOne2DBooleanArray()
        Decode a 2D boolean array from the data field.
        Returns:
        the decoded 2D boolean array.
      • decodeOne2DCharacterArray

        public char[][] decodeOne2DCharacterArray()
        Decode a 2D character array from the data field.
        Returns:
        the decoded 2D character array.
      • decodeOne2DShortArray

        public short[][] decodeOne2DShortArray()
        Decode a 2D short array from the data field.
        Returns:
        the decoded 2D short array.
      • decodeOne2DIntegerArray

        public int[][] decodeOne2DIntegerArray()
        Decode a 2D integer array from the data field.
        Returns:
        the decoded 2D integer array.
      • decodeOne2DLongArray

        public long[][] decodeOne2DLongArray()
        Decode a 2D long array from the data field.
        Returns:
        the decoded 2D long array.
      • decodeOne2DFloatArray

        public float[][] decodeOne2DFloatArray()
        Decode a 2D float array from the data field.
        Returns:
        the decoded 2D float array.
      • decodeOne2DDoubleArray

        public double[][] decodeOne2DDoubleArray()
        Decode a 2D double array from the data field.
        Returns:
        the decoded 2D double array.
      • decodeOneStringArray

        public java.lang.String[] decodeOneStringArray()
        Decode a string array from the data field.
        Returns:
        the decoded string array.
      • decodeOneAddressArray

        public Address[] decodeOneAddressArray()
        Decode an address array from the data field.
        Returns:
        the decoded address array.
      • decodeOneBigIntegerArray

        public java.math.BigInteger[] decodeOneBigIntegerArray()
        Decode a BigInteger array from the data field.
        Returns:
        the decoded BigInteger array.