Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

eth_signTransaction not supported #408

Closed
wolever opened this issue Nov 21, 2018 · 8 comments
Closed

eth_signTransaction not supported #408

wolever opened this issue Nov 21, 2018 · 8 comments

Comments

@wolever
Copy link

wolever commented Nov 21, 2018

As of Ganache 6.2.1, using web3.eth.signTransaction(...) returns Method eth_signTransaction not supported.

We run our test suite against ganache, and some tests can't run because of this.

@davidmurdoch
Copy link
Member

Thanks @wolever for filing this issue. We haven't intentionally removed any features in ganache-cli@6.2.x, so this would be a regression if we did!

Whats the most recent version of ganache-cli that doesn't cause test failures for you?

@mikeseese
Copy link
Contributor

So I think we misread that this maybe was a regression, but looking over again, it looks like what we thought: we don't support this yet, and never have. Added to the list! Thanks!

@davidmurdoch davidmurdoch transferred this issue from trufflesuite/ganache-ui Apr 9, 2019
@szerintedmi
Copy link

szerintedmi commented Apr 15, 2019

I think it has been fixed.
I'm on Ganache CLI v6.4.2 (ganache-core: 2.5.4) and I can sign using web3js-beta36:

web3.eth.accounts.signTransaction(txToSign, privateKey)

@nivida
Copy link

nivida commented Apr 15, 2019

web3.eth.accounts.signTransaction !== web3.eth.signTransaction :) @szerintedmi

@szerintedmi
Copy link

hoops :)

@davidmurdoch
Copy link
Member

eth_signTransaction is not currently part of the Ethereum JSON-RPC spec. Here is the EIP issue proposing to add it: ethereum/EIPs#728

With that said, it looks like geth and parity already support it, as well as web3 and MetaMask.

As long as geth and parity agree on the implementation I don't see any harm in adding it to gananche.

@CJ42
Copy link

CJ42 commented Aug 10, 2021

I solved this by creating new accounts using `web3.eth.accounts.wallet.create(x)' (where x = number of accounts I want to generate).

I then associated the newly created accounts to some global variables accessible through my tests. See below:

contract("My Contract", async (accounts) => {

    let firstAccount,
        secondAccount,
        thirdAccount

    before(async () => {
        await web3.eth.accounts.wallet.create(3) // create 3 accounts

        firstAccount = web3.eth.accounts.wallet[0]
        secondAccount = web3.eth.accounts.wallet[1]
        thirdAccount = web3.eth.accounts.wallet[2]
    })

    // tests here...

})

I was then able to sign data within my tests, using either the:

  • privateKey property
    or
    sign(...) method, available in each of these new accounts

I could then sign in two ways

// method 1
web3.eth.accounts.wallet[firstAccount].sign("Message To Sign")

// method 2
web3.eth.accounts.sign("Message To Sign", firstAccount.privateKey)

See response on Ethereum StackExchange question: Sign data with private key inside a truffle test file

@MicaiahReid
Copy link
Contributor

This has been implemented in Ganache v7. See our Upgrade Guide if you want to use this feature!

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

No branches or pull requests

8 participants