icon-sdk-js
icon-sdk-js copied to clipboard
Example Issue
Hi~ I tried to use examples about 'icon-sdk-js' .
I Just did Copy & Paste
const httpProvider = new HttpProvider('https://ctz.solidwallet.io/api/v3');
const iconService = new IconService(httpProvider);
above code.
And run the code with nodejs. But I occur "ERROR" about HttpProvider is not defined.
const httpProvider = new HttpProvider('https://ctz.solidwallet.io/api/v3');
^
ReferenceError: HttpProvider is not defined
I cannot tried any more.
Plz check there issue.
Could you try this?
import IconService from 'icon-sdk-js';
const { HttpProvider } = IconService;
const httpProvider = new HttpProvider("https://ctz.solidwallet.io/api/v3");
const iconService = new IconService(httpProvider);
also other kind of error
/~/test-icx.js:3 const httpProvider = new HttpProvider("https://ctz.solidwallet.io/api/v3"); ^
TypeError: HttpProvider is not a constructor
at Object.
Have you tried the following ?
import IconService from 'icon-sdk-js';
const httpProvider = new IconService.HttpProvider('https://ctz.solidwallet.io/api/v3');
const iconService = new IconService(httpProvider);
related issue : https://github.com/icon-project/icon-sdk-js/issues/43
Has anyone face this issue: I am using es6 and tried with both node v18 and v16 didn't work....anybody has any solution?
@viveksharmapoudel , @sangbeomji89 From version 1.4.0, modules such as HttpProver are exported at the top level of the library. Try latest version.