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

hardhat-ethers.SignerWithAddress.signMessage broken on hardhat network #1972

Closed
cytadela8 opened this issue Oct 21, 2021 · 3 comments
Closed
Labels
type:feature Feature request

Comments

@cytadela8
Copy link

Summary

Calling signMessage on a signer returned by ethers.getSigners() when using hardhat network results with following error:

     MethodNotFoundError: Method personal_sign not found
      at HardhatNetworkProvider._send (node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:208:11)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async HardhatNetworkProvider.request (node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:108:18)
      at async EthersProviderWrapper.send (node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)

Code

Test producing the above error:

import { expect } from "chai";
import { ethers } from "hardhat";

describe("Test signing", function () {
  it("sign", async function () {
    const [account] = await ethers.getSigners();
    console.log(await account.signMessage("test"));
  });
});

Full repository with the test failing: https://github.com/cytadela8/hardhat-issue-sign-failed/

Steps to reproduce

$ npm install hardhat
$ npx hardhat  # choose advanced project with typescript
$ vim test/index.ts   # Create a test as above
$ npx hardhat test  # Test fails with exception as above
@cytadela8
Copy link
Author

This issue seems to be some new-ish regression. .signMessage worked for me ~month ago. It started failing after reinstalling node dependencies.

@fvictorio
Copy link
Member

Thanks for reporting this @cytadela8. This seems to be a change introduced in ethers@5.5.0, see this issue. For the time being, a workaround is to downgrade to 5.4.x, although I understand that's not ideal. Alternatively, you can use this helper:

function sign(address: string, data: string) {
  return hre.network.provider.send(
    "eth_sign",
    [address, ethers.utils.hexlify(ethers.utils.toUtf8Bytes('foo'))]
  )
}

// ...

const [signer] = await ethers.getSigners()
const signed = await sign(signer.address, 'test')

I guess we should implement the personal_sign RPC method to fix this.

@alcuadrado
Copy link
Member

Thanks for reporting this, @cytadela8. I'll close this issue, as I just opened one more specific.

CJ42 added a commit to lukso-network/lsp-smart-contracts that referenced this issue Nov 10, 2021
CJ42 added a commit to lukso-network/lsp-smart-contracts that referenced this issue Nov 18, 2021
* feat: ➕ add in `package.json`: hardhat-deploy community plugin + dotenv

Enable to write deployment scripts for specific networks, providing private key in `.env` file

* feat: 🔨 add simple UniversalProfile deployment script

* chore: 🙈 add deployments/ folder in `.gitignore`

* chore: 🔧 change `hardhat.config.ts` with new L14 RPC rpc endpoint

* chore: create deployment script for standard contracts

* chore: 🔨 add deployment scripts for base contracts (for proxy usage)

* chore: edit gasPrice provided to ensure deployment + correct 'standard' tags

* fix: 🐛 initialize base contracts to the zero address after deployment

* refactor: use fix gasPrice to ensure deployment on L14

* refactor: use "base" flag to deploy base contracts (to be used behind proxies)

* build: 📦 add hardhat-deploy + .env dependencies in `package-lock.json`

`.env` file required to add private key into and deploy on L14

* build: ➖ remove `dotenv` dependency

* ci: 💚 fix failing CI by sticking to ethers < 5.5.0

See this issue: NomicFoundation/hardhat#1972

* ci: 💚 fix MythX failing CI

* ci: 💚 fix MythX for tokens contracts paths

* refactor: 🚚 use new contracts names in deployment scripts

* ci: 💚 update `package-lock` to fix CI test failing

* refactor: ⚰️ remove deployment scripts for `LSP7` and `LSP8`

this contract are unusable as standalone, and need to be implemented

* docs: 📝 add documentation for deployment scripts in `CONTRIBUTING.md`

* refactor: 🚚 fix contract paths for MythX CI

* docs: 📝 add explanation for tags `standard` and `base` + fix typo

* docs: remove `>` (blockquote) to display available `--tags`

* refactor: display gasLimit with `_` thousand seperators

* docs: create `DEPLOYMENT.md` page with ref from README
wtait pushed a commit to wtait/signatorio that referenced this issue Jun 8, 2022
attempting to sign messages in test using, ex: signer.signMessage('test') was throwing

MethodNotFoundError: Method personal_sign not found

rolling back to 5.4.x seems to have removed this error for now.
see for reference: NomicFoundation/hardhat#1972
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:feature Feature request
Projects
None yet
Development

No branches or pull requests

3 participants