/** * Construct a new Web3j instance. * * @param web3jService web3j service instance - i.e. HTTP or IPC * @return new Web3j instance */ static Web3j build(Web3jService web3jService) { return new JsonRpc2_0Web3j(web3jService); }
@Override public Request<?, ParityAddressesResponse> parityImportGethAccounts( ArrayList<String> gethAddresses) { return new Request<>( "parity_importGethAccounts", gethAddresses, web3jService, ParityAddressesResponse.class); }
public Flowable<T> flowable() { return new RemoteCall<>(this::send).flowable(); } }
@Test public void testEthGetBlockTransactionCountByNumber() throws Exception { web3j.ethGetBlockTransactionCountByNumber( DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8"))).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockTransactionCountByNumber\"," + "\"params\":[\"0xe8\"],\"id\":1}"); }
@Test public void testEthCall() throws Exception { web3j.ethCall(Transaction.createEthCallTransaction( "0xa70e8dd61c5d32be8058bb8eb970870f07233155", "0xb60e8dd61c5d32be8058bb8eb970870f07233155", "0x0"), DefaultBlockParameter.valueOf("latest")).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_call\"," + "\"params\":[{\"from\":\"0xa70e8dd61c5d32be8058bb8eb970870f07233155\"," + "\"to\":\"0xb60e8dd61c5d32be8058bb8eb970870f07233155\",\"data\":\"0x0\"}," + "\"latest\"],\"id\":1}"); }
@Override public Request<?, EthBlock> ethGetBlockByNumber( DefaultBlockParameter defaultBlockParameter, boolean returnFullTransactionObjects) { return new Request<>( "eth_getBlockByNumber", Arrays.asList( defaultBlockParameter.getValue(), returnFullTransactionObjects), web3jService, EthBlock.class); }
@Test public void testReplayFlowable() throws Exception { run(web3j.replayPastBlocksFlowable( new DefaultBlockParameterNumber(0), new DefaultBlockParameterNumber(EVENT_COUNT), true)); }
private Web3ClientVersion deserialiseWeb3ClientVersionResponse() { buildResponse(RAW_RESPONSE); return deserialiseResponse(Web3ClientVersion.class); } }
static DefaultBlockParameter valueOf(String blockName) { return DefaultBlockParameterName.fromString(blockName); }
@Test public void testEthGetCode() throws Exception { web3j.ethGetCode("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", DefaultBlockParameter.valueOf(Numeric.toBigInt("0x2"))).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCode\"," + "\"params\":[\"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\",\"0x2\"],\"id\":1}"); }
@Test public void testEthGetTransactionByBlockNumberAndIndex() throws Exception { web3j.ethGetTransactionByBlockNumberAndIndex( DefaultBlockParameter.valueOf(Numeric.toBigInt("0x29c")), BigInteger.ZERO).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getTransactionByBlockNumberAndIndex\"," + "\"params\":[\"0x29c\",\"0x0\"],\"id\":1}"); }
@Override public Request<?, EthGetBlockTransactionCountByNumber> ethGetBlockTransactionCountByNumber( DefaultBlockParameter defaultBlockParameter) { return new Request<>( "eth_getBlockTransactionCountByNumber", Arrays.asList(defaultBlockParameter.getValue()), web3jService, EthGetBlockTransactionCountByNumber.class); }
@Test public void testEthGetUncleCountByBlockNumber() throws Exception { web3j.ethGetUncleCountByBlockNumber( DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8"))).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getUncleCountByBlockNumber\"," + "\"params\":[\"0xe8\"],\"id\":1}"); }
@Test public void testEthGetBlockByNumber() throws Exception { web3j.ethGetBlockByNumber( DefaultBlockParameter.valueOf(Numeric.toBigInt("0x1b4")), true).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\"," + "\"params\":[\"0x1b4\",true],\"id\":1}"); }
@Test public void testEthGetUncleByBlockNumberAndIndex() throws Exception { web3j.ethGetUncleByBlockNumberAndIndex( DefaultBlockParameter.valueOf(Numeric.toBigInt("0x29c")), BigInteger.ZERO).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getUncleByBlockNumberAndIndex\"," + "\"params\":[\"0x29c\",\"0x0\"],\"id\":1}"); }