blockchainsllc/in3-legacy

In3 examples don't work.

Opened this issue · 3 comments

Steps to reproduce

I am trying to create a web app using the instructions from here:
https://in3.readthedocs.io/en/latest/api-ts.html
and following the examples from here:
https://github.com/slockit/in3/blob/master/examples/src/in3DirectAPI.ts
and I can't get anything to log out.

my versions of in3 and web3 are:

   "web3": "^1.2.9"
    "in3": "^2.1.3",

And I'm using a normal NodeJS server with Express.
This is all I get:

UnhandledPromiseRejectionWarning: Error: tried eth_getBlockByNumber("0x0",false) to https://in3-v2.slock.it/mainnet/nd-2 but failed and can not recover (No nodes found that fullfill the filter criteria ) from wrong response  : Error: No nodes found that fullfill the filter criteria

And this is after a day of trying to request different hashes by blocks, numbers, etc.. The previous error is by copying the code from : https://github.com/slockit/in3/blob/master/examples/src/in3DirectAPI.ts

Expected behavior

Anything should login when I try to get information with the hash given in the test.

Actual behavior

I get errors.

Screenshot 2020-07-06 at 21 02 17

System configuration

MacOS 10.15.1

Incubed version

"in3": "^2.1.3",

Request

Incubed Configuration

Chain

Hi thanks for the feedback.
Since we are currently preparing to replace this typescript-implementation by a pure wasm-impl, I would suggest to use in3-wasm instead. We API is (almost) the same, so your code should work with the wasm-version as well.

See
https://in3.readthedocs.io/en/develop/api-wasm.html#use-web3

The in3-wasm-version has the advantage that it adds only a small footprint and zero dependencies and runs with almost native speed. So please let me know if it works for you.

I got this working by using the in3-wasm as I too was getting the same error as @VanessaPC, however, I did some changes to this Example, the changes were needed because of the below error:

SyntaxError: The requested module 'in3-wasm' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export. For example: import pkg from 'in3-wasm'; const { IN3 } = pkg;

const in3wasm = require('in3-wasm');
const Web3 = require('web3')

const in3 = new in3wasm.IN3({
    proof: 'standard',
    signatureCount: 1,
    requestCount: 1,
    chainId: 'mainnet',
    replaceLatestBlock: 10
})

// use the In3Client as Http-Provider
const web3 = new Web3(in3.createWeb3Provider());

(async () => {

    // use the web3
    const block = await web3.eth.getBlock('latest')
    console.log("Block : ", block)

})().catch(console.error);

@simon-jentzsch, thanks I'll have a look at that. I actually like it will come with TS.
@balajipachai Thanks, I'll have a look at this. Actually, now that I think of it, your solution is good, it's even better they adding TS in this case, because if everything goes type-checked it'll avoid this issues and speed up the resulting app.
Thanks to both!