Java Code Examples for org.web3j.abi.datatypes.Utf8String

The following examples show how to use org.web3j.abi.datatypes.Utf8String. These examples are extracted from open source projects. 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 Project: client-sdk-java   Source File: TypeDecoder.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
static <T extends Type> T decode(String input, int offset, Class<T> type) {
    if (NumericType.class.isAssignableFrom(type)) {
        return (T) decodeNumeric(input.substring(offset), (Class<NumericType>) type);
    } else if (Address.class.isAssignableFrom(type)) {
        return (T) decodeAddress(input.substring(offset));
    } else if (Bool.class.isAssignableFrom(type)) {
        return (T) decodeBool(input, offset);
    } else if (Bytes.class.isAssignableFrom(type)) {
        return (T) decodeBytes(input, offset, (Class<Bytes>) type);
    } else if (DynamicBytes.class.isAssignableFrom(type)) {
        return (T) decodeDynamicBytes(input, offset);
    } else if (Utf8String.class.isAssignableFrom(type)) {
        return (T) decodeUtf8String(input, offset);
    } else if (Array.class.isAssignableFrom(type)) {
        throw new UnsupportedOperationException(
                "Array types must be wrapped in a TypeReference");
    } else {
        throw new UnsupportedOperationException(
                "Type cannot be encoded: " + type.getClass());
    }
}
 
Example 2
private MethodSpec.Builder addTypes(MethodSpec.Builder builder, String packageName) {
    builder = addStatement(builder, packageName,
            Address.TYPE_NAME, Address.class.getSimpleName());

    builder = addStatement(builder, packageName,
            Bool.TYPE_NAME, Bool.class.getSimpleName());

    builder = addStatement(builder, packageName,
            Utf8String.TYPE_NAME, Utf8String.class.getSimpleName());

    builder = addStatement(builder, packageName,
            DynamicBytes.TYPE_NAME, DynamicBytes.class.getSimpleName());

    // TODO: Fixed array & dynamic array support
    return builder;
}
 
Example 3
Source Project: client-sdk-java   Source File: UtilsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testGetTypeName() throws ClassNotFoundException {
    assertThat(Utils.getTypeName(new TypeReference<Uint>(){}), is("uint256"));
    assertThat(Utils.getTypeName(new TypeReference<Int>(){}), is("int256"));
    assertThat(Utils.getTypeName(new TypeReference<Ufixed>(){}), is("ufixed256"));
    assertThat(Utils.getTypeName(new TypeReference<Fixed>(){}), is("fixed256"));

    assertThat(Utils.getTypeName(new TypeReference<Uint64>(){}), is("uint64"));
    assertThat(Utils.getTypeName(new TypeReference<Int64>(){}), is("int64"));
    assertThat(Utils.getTypeName(new TypeReference<Bool>(){}), is("bool"));
    assertThat(Utils.getTypeName(new TypeReference<Utf8String>(){}), is("string"));
    assertThat(Utils.getTypeName(new TypeReference<DynamicBytes>(){}), is("bytes"));

    assertThat(Utils.getTypeName(
            new TypeReference.StaticArrayTypeReference<StaticArray<Uint>>(5){}),
            is("uint256[5]"));
    assertThat(Utils.getTypeName(
            new TypeReference<DynamicArray<Uint>>(){}),
            is("uint256[]"));
}
 
Example 4
Source Project: client-sdk-java   Source File: AbiTypesMapperGenerator.java    License: Apache License 2.0 6 votes vote down vote up
private MethodSpec.Builder addTypes(MethodSpec.Builder builder, String packageName) {
    builder = addStatement(builder, packageName,
            Address.TYPE_NAME, Address.class.getSimpleName());

    builder = addStatement(builder, packageName,
            Bool.TYPE_NAME, Bool.class.getSimpleName());

    builder = addStatement(builder, packageName,
            Utf8String.TYPE_NAME, Utf8String.class.getSimpleName());

    builder = addStatement(builder, packageName,
            DynamicBytes.TYPE_NAME, DynamicBytes.class.getSimpleName());

    // TODO: Fixed array & dynamic array support
    return builder;
}
 
Example 5
Source Project: client-sdk-java   Source File: StakingParam.java    License: Apache License 2.0 6 votes vote down vote up
public List<Type> getSubmitInputParameters() {
    return Arrays.<Type>asList(new Uint16(stakingAmountType.getValue())
            , new BytesType(Numeric.hexStringToByteArray(benifitAddress))
            , new BytesType(Numeric.hexStringToByteArray(nodeId))
            , new Utf8String(externalId)
            , new Utf8String(nodeName)
            , new Utf8String(webSite)
            , new Utf8String(details)
            , new Int256(amount)
            , new Uint16(rewardPer)
            , new Uint32(processVersion.getProgramVersion())
            , new BytesType(Numeric.hexStringToByteArray(processVersion.getProgramVersionSign()))
            , new BytesType(Numeric.hexStringToByteArray(blsPubKey))
            , new BytesType(Numeric.hexStringToByteArray(blsProof))
    );
}
 
Example 6
Source Project: client-sdk-java   Source File: PayWages.java    License: Apache License 2.0 6 votes vote down vote up
public RemoteCall<Tuple4<BigInteger, BigInteger, String, String>> getEmployee(String _account) {
	final Function function = new Function(FUNC_GETEMPLOYEE, Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(_account)),
			Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {
			}, new TypeReference<Uint8>() {
			}, new TypeReference<Utf8String>() {
			}, new TypeReference<Address>() {
			}));
	return new RemoteCall<Tuple4<BigInteger, BigInteger, String, String>>(new Callable<Tuple4<BigInteger, BigInteger, String, String>>() {
		@Override
		public Tuple4<BigInteger, BigInteger, String, String> call() throws Exception {
			List<Type> results = executeCallMultipleValueReturn(function);
			return new Tuple4<BigInteger, BigInteger, String, String>((BigInteger) results.get(0).getValue(),
					(BigInteger) results.get(1).getValue(), (String) results.get(2).getValue(), (String) results.get(3).getValue());
		}
	});
}
 
Example 7
private String sendCreateContractTransaction() throws Exception {
    BigInteger nonce = getNonce(ALICE.getAddress());

    String encodedConstructor =
            FunctionEncoder.encodeConstructor(Collections.singletonList(new Utf8String(VALUE)));

    Transaction transaction = Transaction.createContractTransaction(
            ALICE.getAddress(),
            nonce,
            GAS_PRICE,
            GAS_LIMIT,
            BigInteger.ZERO,
            getGreeterSolidityBinary() + encodedConstructor);

    org.web3j.protocol.core.methods.response.EthSendTransaction
            transactionResponse = web3j.ethSendTransaction(transaction)
            .sendAsync().get();

    return transactionResponse.getTransactionHash();
}
 
Example 8
@SuppressWarnings("unchecked")
static <T extends Type> T decode(String input, int offset, Class<T> type) {
    if (NumericType.class.isAssignableFrom(type)) {
        return (T) decodeNumeric(input.substring(offset), (Class<NumericType>) type);
    } else if (Address.class.isAssignableFrom(type)) {
        return (T) decodeAddress(input.substring(offset));
    } else if (Bool.class.isAssignableFrom(type)) {
        return (T) decodeBool(input, offset);
    } else if (Bytes.class.isAssignableFrom(type)) {
        return (T) decodeBytes(input, offset, (Class<Bytes>) type);
    } else if (DynamicBytes.class.isAssignableFrom(type)) {
        return (T) decodeDynamicBytes(input, offset);
    } else if (Utf8String.class.isAssignableFrom(type)) {
        return (T) decodeUtf8String(input, offset);
    } else if (Array.class.isAssignableFrom(type)) {
        throw new UnsupportedOperationException(
                "Array types must be wrapped in a TypeReference");
    } else {
        throw new UnsupportedOperationException(
                "Type cannot be encoded: " + type.getClass());
    }
}
 
Example 9
@Test
public void testGetNativeType() {
    assertThat(getNativeType(TypeName.get(Address.class)),
            equalTo(TypeName.get(String.class)));
    assertThat(getNativeType(TypeName.get(Uint256.class)),
            equalTo(TypeName.get(BigInteger.class)));
    assertThat(getNativeType(TypeName.get(Int256.class)),
            equalTo(TypeName.get(BigInteger.class)));
    assertThat(getNativeType(TypeName.get(Utf8String.class)),
            equalTo(TypeName.get(String.class)));
    assertThat(getNativeType(TypeName.get(Bool.class)),
            equalTo(TypeName.get(Boolean.class)));
    assertThat(getNativeType(TypeName.get(Bytes32.class)),
            equalTo(TypeName.get(byte[].class)));
    assertThat(getNativeType(TypeName.get(DynamicBytes.class)),
            equalTo(TypeName.get(byte[].class)));
}
 
Example 10
@Test
public void testStaticArray() {
    assertThat(TypeDecoder.decodeStaticArray(
            "000000000000000000000000000000000000000000000000000000000000000a"
            + "0000000000000000000000000000000000000000000000007fffffffffffffff",
            0,
            new TypeReference.StaticArrayTypeReference<StaticArray<Uint256>>(2) {},
            2),
            is(new StaticArray<Uint256>(
                    new Uint256(BigInteger.TEN),
                    new Uint256(BigInteger.valueOf(Long.MAX_VALUE)))));

    assertThat(TypeDecoder.decodeStaticArray(
                    "000000000000000000000000000000000000000000000000000000000000000d"
                    + "48656c6c6f2c20776f726c642100000000000000000000000000000000000000"
                    + "000000000000000000000000000000000000000000000000000000000000000d"
                    + "776f726c64212048656c6c6f2c00000000000000000000000000000000000000",
            0,
            new TypeReference.StaticArrayTypeReference<StaticArray<Utf8String>>(2){},
            2
            ),
            equalTo(new StaticArray<Utf8String>(
                    new Utf8String("Hello, world!"),
                    new Utf8String("world! Hello,"))));
}
 
Example 11
@Test
public void testSimpleFunctionStringResultDecode() {
    Function function = new Function("simple",
            Arrays.asList(),
            Collections.singletonList(new TypeReference<Utf8String>() {
            }));

    List<Type> utf8Strings = FunctionReturnDecoder.decode(

            "0x0000000000000000000000000000000000000000000000000000000000000020"
                    + "000000000000000000000000000000000000000000000000000000000000000d"
                    + "6f6e65206d6f72652074696d6500000000000000000000000000000000000000",
            function.getOutputParameters());

    assertThat(utf8Strings.get(0).getValue(), is("one more time"));
}
 
Example 12
public Observable<NameChangedEventResponse> nameChangedEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    final Event event = new Event("NameChanged", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Bytes32>() {}),
            Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}));
    EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
    filter.addSingleTopic(EventEncoder.encode(event));
    return web3j.ethLogObservable(filter).map(new Func1<Log, NameChangedEventResponse>() {
        @Override
        public NameChangedEventResponse call(Log log) {
            EventValues eventValues = extractEventParameters(event, log);
            NameChangedEventResponse typedResponse = new NameChangedEventResponse();
            typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue();
            typedResponse.name = (String) eventValues.getNonIndexedValues().get(0).getValue();
            return typedResponse;
        }
    });
}
 
Example 13
Source Project: etherscan-explorer   Source File: UtilsTest.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testGetTypeName() throws ClassNotFoundException {
    assertThat(Utils.getTypeName(new TypeReference<Uint>(){}), is("uint256"));
    assertThat(Utils.getTypeName(new TypeReference<Int>(){}), is("int256"));
    assertThat(Utils.getTypeName(new TypeReference<Ufixed>(){}), is("ufixed256"));
    assertThat(Utils.getTypeName(new TypeReference<Fixed>(){}), is("fixed256"));

    assertThat(Utils.getTypeName(new TypeReference<Uint64>(){}), is("uint64"));
    assertThat(Utils.getTypeName(new TypeReference<Int64>(){}), is("int64"));
    assertThat(Utils.getTypeName(new TypeReference<Bool>(){}), is("bool"));
    assertThat(Utils.getTypeName(new TypeReference<Utf8String>(){}), is("string"));
    assertThat(Utils.getTypeName(new TypeReference<DynamicBytes>(){}), is("bytes"));

    assertThat(Utils.getTypeName(
            new TypeReference.StaticArrayTypeReference<StaticArray<Uint>>(5){}),
            is("uint256[5]"));
    assertThat(Utils.getTypeName(
            new TypeReference<DynamicArray<Uint>>(){}),
            is("uint256[]"));
}
 
Example 14
Source Project: client-sdk-java   Source File: FunctionReturnDecoder.java    License: Apache License 2.0 5 votes vote down vote up
private static <T extends Type> int getDataOffset(String input, int offset, Class<T> type) {
    if (DynamicBytes.class.isAssignableFrom(type)
            || Utf8String.class.isAssignableFrom(type)
            || DynamicArray.class.isAssignableFrom(type)) {
        return TypeDecoder.decodeUintAsInt(input, offset) << 1;
    } else {
        return offset;
    }
}
 
Example 15
Source Project: client-sdk-java   Source File: PlatOnTypeDecoder.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T extends Type> T decode(byte[] data, Class<T> type) {
    if (NumericType.class.isAssignableFrom(type)) {
        return (T) decodeNumeric(data, (Class<NumericType>) type);
    } else if (Utf8String.class.isAssignableFrom(type)) {
        return (T)decodeUtf8String(data); 
    } else {
        throw new UnsupportedOperationException(
                "Type cannot be encoded: " + type.getClass());
    }
}
 
Example 16
Source Project: client-sdk-java   Source File: PlatOnTypeEncoder.java    License: Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example 17
Source Project: client-sdk-java   Source File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
static String getSimpleTypeName(Class<?> type) {
    String simpleName = type.getSimpleName().toLowerCase();

    if (type.equals(Uint.class) || type.equals(Int.class)
            || type.equals(Ufixed.class) || type.equals(Fixed.class)) {
        return simpleName + "256";
    } else if (type.equals(Utf8String.class)) {
        return "string";
    } else if (type.equals(DynamicBytes.class)) {
        return "bytes";
    } else {
        return simpleName;
    }
}
 
Example 18
Source Project: client-sdk-java   Source File: TypeEncoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testUtf8String() {
    Utf8String string = new Utf8String("Hello, world!");
    assertThat(TypeEncoder.encodeString(string),
            is("000000000000000000000000000000000000000000000000000000000000000d"
                    + "48656c6c6f2c20776f726c642100000000000000000000000000000000000000"));
}
 
Example 19
Source Project: client-sdk-java   Source File: TypeDecoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testUtf8String() {
    assertThat(TypeDecoder.decodeUtf8String(
            "000000000000000000000000000000000000000000000000000000000000000d"  // length
                    + "48656c6c6f2c20776f726c642100000000000000000000000000000000000000", 0),
            is(new Utf8String("Hello, world!")));
}
 
Example 20
Source Project: alpha-wallet-android   Source File: EnsResolver.java    License: MIT License 5 votes vote down vote up
private Function getName(byte[] nameHash)
{
    return new Function("name",
                        Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(nameHash)),
                        Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>()
                        {
                        }));
}
 
Example 21
Source Project: client-sdk-java   Source File: TypeDecoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testDynamicArray() {
    assertThat(TypeDecoder.decodeDynamicArray(
            "0000000000000000000000000000000000000000000000000000000000000000",  // length
            0,
            new TypeReference<DynamicArray<Uint256>>() { }
            ),
            equalTo(DynamicArray.empty("uint256")));

    assertThat(TypeDecoder.decodeDynamicArray(
            "0000000000000000000000000000000000000000000000000000000000000002"  // length
                    + "000000000000000000000000000000000000000000000000000000000000000a"
                    + "0000000000000000000000000000000000000000000000007fffffffffffffff",
            0,
            new TypeReference<DynamicArray<Uint256>>() { }
            ),
            equalTo(new DynamicArray<Uint256>(
                    new Uint256(BigInteger.TEN),
                    new Uint256(BigInteger.valueOf(Long.MAX_VALUE)))));

    assertThat(TypeDecoder.decodeDynamicArray(
            "0000000000000000000000000000000000000000000000000000000000000002"  // length
                    + "000000000000000000000000000000000000000000000000000000000000000d"
                    + "48656c6c6f2c20776f726c642100000000000000000000000000000000000000"
                    + "000000000000000000000000000000000000000000000000000000000000000d"
                    + "776f726c64212048656c6c6f2c00000000000000000000000000000000000000",
            0,
            new TypeReference<DynamicArray<Utf8String>>() { }
            ),
            equalTo(new DynamicArray<Utf8String>(
                    new Utf8String("Hello, world!"),
                    new Utf8String("world! Hello,"))));
}
 
Example 22
Source Project: client-sdk-java   Source File: FunctionReturnDecoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testFunctionEmptyStringResultDecode() {
    Function function = new Function("test",
            Collections.emptyList(),
            Collections.singletonList(new TypeReference<Utf8String>() {
            }));

    List<Type> utf8Strings = FunctionReturnDecoder.decode(
            "0x0000000000000000000000000000000000000000000000000000000000000020"
                    + "0000000000000000000000000000000000000000000000000000000000000000",
            function.getOutputParameters());

    assertThat(utf8Strings.get(0).getValue(), is(""));
}
 
Example 23
Source Project: eventeum   Source File: EventEmitter.java    License: Apache License 2.0 5 votes vote down vote up
public RemoteFunctionCall<TransactionReceipt> emitEventNotOrdered(byte[] value1, BigInteger value2, String value3) {
    final Function function = new Function(
            FUNC_EMITEVENTNOTORDERED, 
            Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(value1), 
            new org.web3j.abi.datatypes.generated.Uint256(value2), 
            new org.web3j.abi.datatypes.Utf8String(value3)), 
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example 24
Source Project: client-sdk-java   Source File: PlatOnTypeDecoderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testUtf8String() {
    assertThat(PlatOnTypeDecoder.decode(
    		Numeric.hexStringToByteArray("48656c6c6f2c20776f726c6421"), 
    		Utf8String.class),
            is(new Utf8String("Hello, world!")));
}
 
Example 25
public RemoteCall<TransactionReceipt> setText(byte[] node, String key, String value) {
    Function function = new Function(
            "setText", 
            Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Bytes32(node),
            new org.web3j.abi.datatypes.Utf8String(key),
            new org.web3j.abi.datatypes.Utf8String(value)),
            Collections.<TypeReference<?>>emptyList());
    return executeRemoteCallTransaction(function);
}
 
Example 26
Source Project: client-sdk-java   Source File: SolidityFunctionWrapper.java    License: Apache License 2.0 5 votes vote down vote up
static TypeName getEventNativeType(TypeName typeName) {
    if (typeName instanceof ParameterizedTypeName) {
        return TypeName.get(byte[].class);
    }

    String simpleName = ((ClassName) typeName).simpleName();
    if (simpleName.equals(Utf8String.class.getSimpleName())) {
        return TypeName.get(byte[].class);
    } else {
        return getNativeType(typeName);
    }
}
 
Example 27
@Test
public void testBuildTypeName() {
    assertThat(buildTypeName("uint256"),
            is(ClassName.get(Uint256.class)));
    assertThat(buildTypeName("uint64"),
            is(ClassName.get(Uint64.class)));
    assertThat(buildTypeName("string"),
            is(ClassName.get(Utf8String.class)));

    assertThat(buildTypeName("uint256[]"),
            is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[] storage"),
            is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[] memory"),
            is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[10]"),
            is(ParameterizedTypeName.get(StaticArray10.class, Uint256.class)));

    assertThat(buildTypeName("uint256[33]"),
            is(ParameterizedTypeName.get(StaticArray.class, Uint256.class)));

    assertThat(buildTypeName("uint256[10][3]"),
            is(ParameterizedTypeName.get(ClassName.get(StaticArray3.class),
                    ParameterizedTypeName.get(StaticArray10.class, Uint256.class))));

    assertThat(buildTypeName("uint256[2][]"),
            is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(StaticArray2.class, Uint256.class))));

    assertThat(buildTypeName("uint256[33][]"),
            is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(StaticArray.class, Uint256.class))));

    assertThat(buildTypeName("uint256[][]"),
            is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class),
                    ParameterizedTypeName.get(DynamicArray.class, Uint256.class))));
}
 
Example 28
Source Project: alpha-wallet-android   Source File: EnsResolver.java    License: MIT License 5 votes vote down vote up
private Function get(BigInteger nameId)
{
    return new Function("get",
                        Arrays.<Type>asList(new org.web3j.abi.datatypes.Utf8String(EnsResolver.CRYPTO_ETH_KEY), new org.web3j.abi.datatypes.generated.Uint256(nameId)),
                        Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>()
                        {
                        }));
}
 
Example 29
Source Project: client-sdk-java   Source File: UpdateStakingParam.java    License: Apache License 2.0 5 votes vote down vote up
public List<Type> getSubmitInputParameters() {
    return Arrays.asList(new BytesType(Numeric.hexStringToByteArray(benifitAddress)),
            new BytesType(Numeric.hexStringToByteArray(nodeId)),
            new Uint16(rewardPer),
            new Utf8String(externalId),
            new Utf8String(nodeName),
            new Utf8String(webSite),
            new Utf8String(details));
}
 
Example 30
@Test
public void testReverseResolve() throws Exception {
    configureSyncing(false);
    configureLatestBlock(System.currentTimeMillis() / 1000);  // block timestamp is in seconds

    NetVersion netVersion = new NetVersion();
    netVersion.setResult(Byte.toString(ChainId.MAINNET));

    String resolverAddress =
            "0x0000000000000000000000004c641fb9bad9b60ef180c31f56051ce826d21a9a";
    String contractName =
            "0x0000000000000000000000000000000000000000000000000000000000000020"
            + TypeEncoder.encode(new Utf8String("web3j.eth"));
    System.err.println(contractName);

    EthCall resolverAddressResponse = new EthCall();
    resolverAddressResponse.setResult(resolverAddress);

    EthCall contractNameResponse = new EthCall();
    contractNameResponse.setResult(contractName);

    when(web3jService.send(any(Request.class), eq(NetVersion.class)))
            .thenReturn(netVersion);
    when(web3jService.send(any(Request.class), eq(EthCall.class)))
            .thenReturn(resolverAddressResponse);
    when(web3jService.send(any(Request.class), eq(EthCall.class)))
            .thenReturn(contractNameResponse);

    assertThat(ensResolver.reverseResolve("0x19e03255f667bdfd50a32722df860b1eeaf4d635"),
            is("web3j.eth"));
}