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

[ERROR] "Missing provider" when calling ethrDid.setAttribute #81

Open
0Alic opened this issue Dec 22, 2021 · 13 comments
Open

[ERROR] "Missing provider" when calling ethrDid.setAttribute #81

0Alic opened this issue Dec 22, 2021 · 13 comments

Comments

@0Alic
Copy link

0Alic commented Dec 22, 2021

Hello, I just approached this library and I have this issue that I cannot solve. Sorry if I am missing a very basic step.

Current Behavior

I create a ethrDid object using the ethrs InfuraProvider as explained here. I provide the private key of one of my Ropsten addresses.
If I call ethrDid.setAttribute() (or any other transaction) I get the error "Missing provider".

Expected Behavior

Execute the ethrDid.setAttribute() function.

Failure Information

reason: 'missing provider',
code: 'UNSUPPORTED_OPERATION',
operation: 'sendTransaction'

(more details below)

Steps to Reproduce

import { EthrDID } from "ethr-did";
import { InfuraProvider } from "@ethersproject/providers";

const infuraProjectId = "abcde"
const myRopstenAddress = "0x..."
const pk = "123456789" // Private key of the address above

async function foo() {

    const chainNameOrId = 3
    const infura = new InfuraProvider("ropsten", infuraProjectId)
    const ethrDid = new EthrDID({identifier: myRopstenAddress, privateKey: pk, provider: infura, chainNameOrId})

    await ethrDid.setAttribute('did/svc/HubService', 'https://hubs.uport.me', 3600)
}

// Execute
foo()

Environment Details

  • node version: v15.11.0
  • OS Version: WSL Debian 1.3.0.0
  • dependencies:
    "@ethersproject/providers": "^5.5.0",
    "@types/node": "^17.0.2",
    "did-jwt": "^5.11.1",
    "did-resolver": "^3.1.3",
    "ethr-did": "^2.1.5",
    "ethr-did-registry": "^0.0.3",
    "ethr-did-resolver": "^5.0.2",
    "ts-node": "^10.4.0",
    "typescript": "^4.5.4",

Failure Logs/Screenshots

https://gist.github.com/0Alic/feb5b04fc05e76bf358c8d81114b228c

Thank you in advance.

@mirceanis
Copy link
Contributor

Thank you for such a detailed report!

I'm unable to verify right now, but it seems like you stumbled upon a bug.
Can you try to use did:ethr:ropsten:${myRopstenAddress} as identifier? Or alternatively set chainNameOrId = "ropsten"?

I think there might be an internal mismatch happening

@0Alic
Copy link
Author

0Alic commented Dec 27, 2021

Hi, thank you for the answer!
I tried to explicit "ropsten" but I get the same error.

Web3HttpProvider: same procedure same error

I observed that the same error rises even if I use the Web3HttpProvider connected to a local ganache instance, in particular:

const Web3HttpProvider = require('web3-providers-http')
const web3Url = config["localhost"]+":"+config["port"]
const web3Provider = new Web3HttpProvider(web3Url)
const ethrsprovider = new ethers.providers.Web3Provider(web3Provider)

const identifier = `did:ethr:${config["chainId"]}:0x1234...`
const aliceDid = await new EthrDID({
      identifier: identifier,
      registry: registryAddress,   // registry contract deployed to ganache
      provider: ethrsprovider,            
      chainNameOrId: config["chainId"], // ganache network id
      privateKey: myPrivateKey,
})

await aliceDid.setAttribute('did/pub/Ed25519/veriKey/base64', "...") // <== !!! rises "missing provider error" !!!

Web3HttpProvider: providing signer fixes

However, providing the signer instead of privateKey fixes the "missing provider error", in particular

//
// [same code as above]
//

const didJwt = require("did-jwt")
const signer = didJwt.ES256KSigner(myPrivateKey, true)

const aliceDid = await new EthrDID({
      identifier: identifier,
      registry: registryAddress,   // registry contract deployed to ganache
      provider: ethrsprovider,            
      chainNameOrId: config["chainId"], // ganache network id
      // privateKey: myPrivateKey,
      signer: signer   // new
})

await aliceDid.setAttribute('did/pub/Ed25519/veriKey/base64', "...") // <==  works as intended

InfuraProvider: providing signer gives another error

Albeit this works for Web3HttpProvider, when using InfuraProvider I get the error API provider does not support signing.

import { EthrDID } from "ethr-did";
import { InfuraProvider } from "@ethersproject/providers";
import { ES256KSigner } from "did-jwt";

const infuraProjectId = "abcde"
const myRopstenAddress = "0x..."
const pk = "123456789" // Private key of the address above
const signer = ES256KSigner(pk, true)
async function foo() {

    const chainNameOrId = "ropsten"
    const infura = new InfuraProvider("ropsten", infuraProjectId)
    const ethrDid = new EthrDID({identifier: "did:ethr:ropsten:"+myRopstenAddress, signer: signer, provider: infura, chainNameOrId})

    await ethrDid.setAttribute('did/svc/HubService', 'https://hubs.uport.me', 3600) // <== !!! rises "API provider does not support signing" !!!
}

// Execute
foo()

Error details: https://gist.github.com/0Alic/717224c842031a17d9f9f86a5ce700f0

Hope I am not doing mistakes.
Thanks

@mirceanis
Copy link
Contributor

mirceanis commented Feb 4, 2022

@0Alic I've been trying to debug the missing provider error based on your very detailed reports (thank you for that!)

There is a fix for the missing provider error, but it leads me to a new, even weirder error which is still blocking me (something about not detecting the network, similar to this).
I'll keep working until I figure it out.

You are on the right track with your last 2 examples.

  • Web3HttpProvider: providing signer fixes -> it worked probably because you were on ganache and the provider also acts as a signer.

  • InfuraProvider: providing signer gives another error -> One more step needed.
    Since you are not passing the private key to the EthrDID constructor, you have to use a transaction Signer.

import { Wallet } from '@ethersproject/wallet'

/// ...

const txSigner = new Wallet(privateKey, infura)
const ethrDid = new EthrDID({identifier: "did:ethr:ropsten:"+myRopstenAddress, signer: signer, txSigner: txSigner, provider: infura, chainNameOrId})

@mirceanis
Copy link
Contributor

Here is a sample that works for me:

import { EthrDID } from "ethr-did";
import { InfuraProvider } from "@ethersproject/providers";
import { Wallet } from "@ethersproject/wallet"

const infuraProjectId = "...."
const { privateKey, address } = EthrDID.createKeyPair()

async function foo() {
  const chainNameOrId = 3 // or "ropsten"
  const provider = new InfuraProvider(3 /* or "ropsten"*/, infuraProjectId)
  const txSigner = new Wallet(privateKey, provider)
  const ethrDid = new EthrDID({
    identifier: address,
    txSigner,
    provider,
    chainNameOrId,
  })

  // throws INSUFFICIENT_FUNDS which means the transaction attempt is made
  await ethrDid.setAttribute('did/svc/HubService', 'https://hubs.uport.me', 3600, 123456)
}

// Execute
foo()

@mirceanis
Copy link
Contributor

This seems to have no recent activity so I will assume it was solved.
Please reopen if this is still an issue.

@Touseef-md
Copy link

@mirceanis I tried your last given code with the dummy account address and private key, it shows insufficient funds but yes the attempt was made.
Whereas when I use real credentials for rinkeby test net then no response comes after the setAttribute function is called. Before calling the setAttribute function I logged the ethrDId , it's getting logged perfectly.
image

The console just kind of hangs there.

@Touseef-md
Copy link

@mirceanis I also tried to check whether there was any transaction on etherscan for my ethereum address, but got nothing.
Hope I've not done anything wrong.

@Touseef-md
Copy link

@mirceanis I've figured out that if I do the same transaction on the front end using meta mask, I have to adjust the gas fee to make the transaction successful.
What I think is that from the backend I'm not adjusting the gas fee so the transaction is pending in the network so the node isn't responding.

Please how to set the gas Price in the setAttribute function, I checked this closed issue , here you've told how to set the gas Price and gas Limit but now the function doesn't support the gas Price parameter it accepts only gasLimit Parameter .
Please help!
Thanks in advance.
Screenshot (486)

@mirceanis
Copy link
Contributor

mirceanis commented Jul 27, 2022

@Touseef-md you can use the txOptions object to specify a particular gasPrice or change the gasLimit.

In the sample code from above, this would look like this:

// ...
  await ethrDid.setAttribute('did/svc/HubService', 'https://hubs.uport.me', 3600, 123456, {
    gasLimit: 100000, // this overrides the `gasLimit` specified as a direct parameter 123456
    gasPrice: 1000000000 // 1 gwei
  })

See about call overrides and Transaction request to get an idea about what you can override.

@Sumitjh26997
Copy link

was this ever resolved, if yes can anyone share the solution again for reference. I am still getting the missing provider error on all operations be it setAtrribute, changeOwner while connecting to a local ganache instance or test nets like ropsten or rinkeby

@simonas-notcat
Copy link
Contributor

I'm getting the same error (Error: missing provider (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=abstract-signer/5.7.0) while trying to use ethr-did with Veramo. Here is a repo that replicates this behavior:
https://github.com/simonas-notcat/veramo-ethr

@simonas-notcat simonas-notcat reopened this Nov 2, 2022
@simonas-notcat
Copy link
Contributor

There is probably something wrong with the new "multi-network" setup. I was able to solve my issue, by using old config format: simonas-notcat/veramo-ethr@83b8feb#diff-bfe5fcdcbcc5b806d61f26909a1ef6cc3b98d63016e6243c3f0326ec4d28be73

@nc163
Copy link

nc163 commented Feb 21, 2023

I got the same error in goerli.
I'm a newbie so I may have missed something.
I can share the code. -> https://github.com/nc163/did-ctrl-example

node -v
v16.13.1

git clone https://github.com/nc163/did-ctrl-example.git
cd did-ctrl-example

** set up .env**

npm i
node src/ddo-update.js

Error: missing provider (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=abstract-signer/5.7.0)
    at Logger.makeError (/Volumes/KIOXIA/Workspace/did-ctrl-example/node_modules/@ethersproject/logger/lib/index.js:238:21)
    at Logger.throwError (/Volumes/KIOXIA/Workspace/did-ctrl-example/node_modules/@ethersproject/logger/lib/index.js:247:20)
    at Wallet.Signer._checkProvider (/Volumes/KIOXIA/Workspace/did-ctrl-example/node_modules/@ethersproject/abstract-signer/lib/index.js:395:20)
    at Wallet.<anonymous> (/Volumes/KIOXIA/Workspace/did-ctrl-example/node_modules/@ethersproject/abstract-signer/lib/index.js:144:30)
    at step (/Volumes/KIOXIA/Workspace/did-ctrl-example/node_modules/@ethersproject/abstract-signer/lib/index.js:48:23)
    at Object.next (/Volumes/KIOXIA/Workspace/did-ctrl-example/node_modules/@ethersproject/abstract-signer/lib/index.js:29:53)
    at /Volumes/KIOXIA/Workspace/did-ctrl-example/node_modules/@ethersproject/abstract-signer/lib/index.js:23:71
    at new Promise (<anonymous>)
    at __awaiter (/Volumes/KIOXIA/Workspace/did-ctrl-example/node_modules/@ethersproject/abstract-signer/lib/index.js:19:12)
    at Wallet.Signer.sendTransaction (/Volumes/KIOXIA/Workspace/did-ctrl-example/node_modules/@ethersproject/abstract-signer/lib/index.js:139:16) {
  reason: 'missing provider',
  code: 'UNSUPPORTED_OPERATION',
  operation: 'sendTransaction'
}

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

6 participants