public static String encodeQuantity(BigInteger value) {
        if (value.signum() != -1) {
            return HEX_PREFIX + value.toString(16);
        } else {
            throw new MessageEncodingException("Negative values are not supported");
        }
    }
@Test
    public void testQuantityEncode() {
        assertEquals(Numeric.encodeQuantity(BigInteger.valueOf(0)), ("0x0"));
        assertEquals(Numeric.encodeQuantity(BigInteger.valueOf(1)), ("0x1"));
        assertEquals(Numeric.encodeQuantity(BigInteger.valueOf(1024)), ("0x400"));
        assertEquals(
                Numeric.encodeQuantity(BigInteger.valueOf(Long.MAX_VALUE)), ("0x7fffffffffffffff"));
        assertEquals(
                Numeric.encodeQuantity(new BigInteger("204516877000845695339750056077105398031")),
                ("0x99dc848b94efc27edfad28def049810f"));
    }