use of org.web3j.protocol.core.methods.response.NetVersion in project web3j by web3j.
the class EnsResolver method lookupResolver.
private PublicResolver lookupResolver(String ensName) throws Exception {
NetVersion netVersion = web3j.netVersion().send();
String registryContract = Contracts.resolveRegistryContract(netVersion.getNetVersion());
ENS ensRegistry = ENS.load(registryContract, web3j, transactionManager, new DefaultGasProvider());
byte[] nameHash = NameHash.nameHashAsBytes(ensName);
String resolverAddress = ensRegistry.resolver(nameHash).send();
return PublicResolver.load(resolverAddress, web3j, transactionManager, new DefaultGasProvider());
}
use of org.web3j.protocol.core.methods.response.NetVersion in project besu by hyperledger.
the class Web3JSupportAcceptanceTest method netVersionCall.
@Test
public void netVersionCall() {
final String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
assumeTrue(osName.contains("mac") || osName.contains("linux"));
final Web3j web3 = Web3j.build(new UnixIpcService(socketPath.toString()));
final Request<?, NetVersion> ethBlockNumberRequest = web3.netVersion();
node.verify(node -> {
try {
assertThat(ethBlockNumberRequest.send().getNetVersion()).isEqualTo(String.valueOf(2018));
} catch (IOException e) {
fail("Web3J net_version call failed", e);
}
});
}
use of org.web3j.protocol.core.methods.response.NetVersion in project web3j by web3j.
the class CoreIT method testNetVersion.
@Test
public void testNetVersion() throws Exception {
NetVersion netVersion = web3j.netVersion().send();
assertFalse(netVersion.getNetVersion().isEmpty());
}
use of org.web3j.protocol.core.methods.response.NetVersion in project web3j by web3j.
the class EnsResolver method getResolverAddress.
private String getResolverAddress(String ensName) throws Exception {
NetVersion netVersion = web3j.netVersion().send();
String registryContract = Contracts.resolveRegistryContract(netVersion.getNetVersion());
ENS ensRegistry = ENS.load(registryContract, web3j, transactionManager, new DefaultGasProvider());
byte[] nameHash = NameHash.nameHashAsBytes(ensName);
String address = ensRegistry.resolver(nameHash).send();
if (EnsUtils.isAddressEmpty(address)) {
address = getResolverAddress(EnsUtils.getParent(ensName));
}
return address;
}
use of org.web3j.protocol.core.methods.response.NetVersion in project web3j by web3j.
the class ResponseTest method testNetVersion.
@Test
public void testNetVersion() throws IOException {
buildResponse("{\n" + " \"id\":67,\n" + " \"jsonrpc\": \"2.0\",\n" + " \"result\": \"59\"\n" + "}");
NetVersion netVersion = deserialiseResponse(NetVersion.class);
assertEquals(netVersion.getNetVersion(), ("59"));
}
Aggregations