org.web3j.abi.datatypes.IntType Java Examples
The following examples show how to use
org.web3j.abi.datatypes.IntType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlatOnTypeEncoder.java From client-sdk-java with Apache License 2.0 | 6 votes |
private static String encodeInt(IntType intType) { byte[] rawValue = toByteArray(intType); byte paddingValue = getPaddingValue(intType); byte[] paddedRawValue = new byte[intType.getBitSize()/8]; if (paddingValue != 0) { for (int i = 0; i < paddedRawValue.length; i++) { paddedRawValue[i] = paddingValue; } } System.arraycopy( rawValue, 0, paddedRawValue, paddedRawValue.length - rawValue.length, rawValue.length); return Numeric.toHexStringNoPrefix(paddedRawValue); }
Example #2
Source File: PlatOnTypeEncoder.java From client-sdk-java with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public static String encode(Type parameter) { if (parameter instanceof IntType) { return encodeInt(((IntType) parameter)); }else if (parameter instanceof Utf8String) { return encodeString((Utf8String) parameter); }else { throw new UnsupportedOperationException( "Type cannot be encoded: " + parameter.getClass()); } }