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

How to add accounts when using Quorum with Web3 1.0? #325

Closed
RobTS opened this issue Mar 27, 2018 · 6 comments
Closed

How to add accounts when using Quorum with Web3 1.0? #325

RobTS opened this issue Mar 27, 2018 · 6 comments
Labels

Comments

@RobTS
Copy link

RobTS commented Mar 27, 2018

System information

Geth version: 1.7.2-stable

OS & Version: OSX with Vagrant container

Branch, Commit Hash or Release: Latest version of Quorum-examples

Expected behaviour

As one way to dig deeper into Quorum and the related tools, I'm trying to set up an ERC20 token on the 7nodes example. I can build it and deploy it using Web3.js, but only using one of the main accounts (from web3.eth.getAccounts()).

When I try to deploy it using an account created and added to the wallet using the below snippet, I get various errors such as "The contract code couldn't be stored, please check your gas limit." and, when I try a second time, "nonce too low". I tried many things to get it to work, but I am out of ideas at this point. I checked for the account balance, but it seems like both have no funds.

let acc = web3.eth.accounts.privateKeyToAccount('...');
web3.eth.accounts.wallet.add(acc);

Can anyone point me to how I can further track down the issue?

Steps to reproduce the behaviour

  1. Launch 7nodes vagrant container
  2. ssh into container
  3. Run raft-init.sh as well as raft-start.sh
  4. Deploy an ERC20 contract using web3.js 1.0 using one of the web3.eth.getAccounts() accounts.
  5. Try the same thing with an account created through the snippet mentioned above, it will fail.

Backtrace

[backtrace]
@RobTS
Copy link
Author

RobTS commented Mar 27, 2018

Code deploying the samples:

Main Account:

web3.eth.getAccounts()
  .then(accounts => {
    return web3.eth.personal.unlockAccount(accounts[0], "", 60000)
      .then(() => {
        return SampleContract.deploy({ data: code, arguments: [100, "StarterToken", 0, "STR"] })
          .send({
            from: accounts[0],
            gas: 1500000,
            gasPrice: '0 '
          })
          .on('error', function (error) {
            console.error(error);
          })
          .on('transactionHash', function (transactionHash) {
            console.log("TransactionHash", transactionHash);
          })
          .on('receipt', function (receipt) {
            console.log("Contract address", receipt.contractAddress) // contains the new contract address
          })
          .on('confirmation', function (confirmationNumber, receipt) {
            console.log("Deployment confirmed!");
          })
      })
  })
  .catch(console.error);

Newly created account:

const acc = web3.eth.accounts.privateKeyToAccount('c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3');
web3.eth.accounts.wallet.add(acc);
web3.eth.getAccounts()
  .then(accounts => {
    return SampleContract.deploy({ data: code, arguments: [100, "StarterToken", 0, "STR"] })
      .send({
        from: web3.eth.accounts.wallet[0].address,
        gas: 1500000,
        gasPrice: '0 '
      })
      .on('error', function (error) {
        console.error(error);
      })
      .on('transactionHash', function (transactionHash) {
        console.log("TransactionHash", transactionHash);
      })
      .on('receipt', function (receipt) {
        console.log("Contract address", receipt.contractAddress) // contains the new contract address
      })
      .on('confirmation', function (confirmationNumber, receipt) {
        console.log("Deployment confirmed!");
      })
  })
  .catch(console.error);

@RobTS
Copy link
Author

RobTS commented Mar 28, 2018

Update: I got so far as to figure out you can add the wallet to the Contract constructor, which then results in a Failed to check for transaction receipt error. Digging deeper, I found this issue, seemingly resolved in geth 1.8.2, which quorum does not use yet: web3/web3.js#1255

@jpmsam jpmsam added the upstream label Apr 7, 2018
@jpmsam
Copy link
Contributor

jpmsam commented Apr 7, 2018

@RobTS Thanks for the update. We'll be working on upgrading Quorum to geth 1.8.2 soon and it should resolve the most recent issue you encountered.

@zhangds007
Copy link

@jpmsam Good news, you are upgrading Quorum to geth 1.8.2. when do you plan to release it? Thank you.

@jpmsam
Copy link
Contributor

jpmsam commented Jun 11, 2018

You can follow PR #392 .

@fixanoid
Copy link
Contributor

Quorum is now on the 1.8.x geth version, so this should now be fully supported.

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

No branches or pull requests

4 participants