Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In3 examples don't work. #58

Open
VanessaPC opened this issue Jul 6, 2020 · 3 comments
Open

In3 examples don't work. #58

VanessaPC opened this issue Jul 6, 2020 · 3 comments

Comments

@VanessaPC
Copy link

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

@simon-jentzsch
Copy link
Contributor

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.

@balajipachai
Copy link

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);

@VanessaPC
Copy link
Author

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@VanessaPC @simon-jentzsch @balajipachai and others