Closed gobberr closed 3 years ago
You can use the rpcUrl
parameter directly in the arguments object for the constructor:
const issuer: Issuer = new EthrDID({ identifier, privateKey, rpcUrl })
If you need to bundle the providerConfig
as an object, then you can use the spread operator: ...providerConfig
const providerConfig = { rpcUrl: 'https://rinkeby.infura.io/<please get an infura project ID>' }
const issuer: Issuer = new EthrDID({
identifier,
privateKey,
...providerConfig
})
This section of the readme details all the parameters you can configure.
If you intend to run on rinkeby
, it's wise to also specify the chainNameOrId
parameter:
const providerConfig = { }
const issuer: Issuer = new EthrDID({
// ...
rpcUrl: 'https://rinkeby.infura.io/<please get an infura project ID>',
chainNameOrId: 'rinkeby'
})
NOTE The RPC URL you are using (https://rinkeby.infura.io/ethr-did) no longer works, please get a free infura project ID or use an alternative provider. You can also specify an ethers.js provider directly, like so:
const issuer: Issuer = new EthrDID({
// ...
provider: new InfuraProvider('rinkeby', <infura project ID>),
chainNameOrId: 'rinkeby'
})
See InfuraProvider or AlchemyProvider
Closing this. Please reopen if the issue is not resolved
Thanks for the answer.
I'm giving as input to the EthrDID constructor an object conforming to the IConfig interface, but I still get the error reported in the screenshot below.
I can't figure out how I can fix it
Does this error only appear in VSCode or is it breaking your build?
This may be obvious already but have you tried a clean build? (clear node_modules, yarn cache clean
, reimport the project in vscode, etc..)
If it is breaking your build, can you isolate the error in a small project that we could look at?
The build breaks and yes I also have already tried to clean up my development environment
You can have a look here, running the file run.ts
with the command ts-node run.ts
That's my situation
I think I see what's happening now, after you shared your project.
the import statement should be import { EthrDID } from "ethr-did";
instead of import EthrDID from "ethr-did";
You seem to have stumbled upon a bug in the docs that are somewhat outdated now.
Here's a sample, based on your project, that works with ts-node
:
import { EthrDID } from "ethr-did";
import { Issuer } from "did-jwt-vc";
const issuer: Issuer = new EthrDID({
identifier: "did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a",
rpcUrl: "https://rinkeby.infura.io/v3/8a581af7416b4e7681d1f871b6945281",
chainNameOrId: "rinkeby",
}) as Issuer;
console.log(issuer);
Now it's works, thanks again!
:tada: This issue has been resolved in version 2.1.5 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
I'm trying to instantiate EthrDID in the following way:
I get this error:
I'm using "ethr-did": "^2.1.4" on package.json
Maybe I'm misconfiguring the providerConfig parameter? Thanks and best regards