Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Can't deploy smart contract using Ledger Nano S as provider for Truffle #508

Open
FilipLaurentiu opened this issue Jun 10, 2020 · 6 comments

Comments

@FilipLaurentiu
Copy link

FilipLaurentiu commented Jun 10, 2020

I can't deploy smart contract using Ledger Nano S as provider for Truffle
Here is my code for deploying on ropsten

const LedgerWalletProvider = require('@ledgerhq/web3-subprovider');
const createLedgerSubprovider = LedgerWalletProvider.default;
const TransportNodeHid = require('@ledgerhq/hw-transport-node-hid-singleton').default;
const ProviderEngine = require('web3-provider-engine');
const RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
// const logger = require("@ledgerhq/logs");

const localNode = 'http://127.0.0.1:8545';

// logger.listen(log => console.log(log));
const getTransport = () => TransportNodeHid.create();
const ledger = createLedgerSubprovider(getTransport, {
    networkId: 3, paths: ["44'/1'/x'/0/0", "44'/1'/0'/x"], askConfirm: false,
});

const engine = new ProviderEngine();
engine.addProvider(ledger);
engine.addProvider(new RpcSubprovider({ rpcUrl: localNode }));
engine.start();

module.exports = engine;

and Truffle config

require("dotenv").config();
const gasPrice = require("./get_gas_price");
const Web3 = require("web3");
const web3 = new Web3();

const LedgerProviderRopsten = require('./ledger-provider-ropsten');
const LedgerProviderMainnet = require('./ledger-provider-mainnet');

module.exports = {
  networks: {
    mainnet: {
      provider: () => LedgerProviderMainnet,
      network_id: 1,
      gasPrice: web3.utils.toWei((gasPrice.fast / 10).toString(), "gwei"),
    },
    ropsten: {
      provider: () => LedgerProviderRopsten,
      network_id: 3,
      gasPrice: web3.utils.toWei("3", "gwei"),
    }
  },
  compilers: {
    solc: {
      version: "0.6.8",
      settings: {
        optimizer: {
          enabled: true
        }
      }
    }
  }
};

The error is

Web3ProviderEngine does not support synchronous requests..

@FilipLaurentiu
Copy link
Author

Truffle v5.1.29 (core: 5.1.29)
Node v10.21.0
@ledgerhq/hw-transport-node-hid-singleton 5.16.0
@ledgerhq/logs 5.15.0
@ledgerhq/web3-subprovider 5.16.0

@FilipLaurentiu FilipLaurentiu changed the title Can't deploy smart contract using @ledgerhq/web3-subprovider Can't deploy smart contract using Ledger Nano S as provider for Truffle Jun 11, 2020
@FilipLaurentiu
Copy link
Author

Mention that using other provider in truffle it work without problem.

    testnet: {
      provider: () => new HDWalletProvider(process.env.MNEMONIC, process.env.BLOCKCHAIN_NODE_ROPSTEN),
      network_id: "*"
    },

@FilipLaurentiu
Copy link
Author

FilipLaurentiu commented Jun 11, 2020

I just remove the gasPrice field from configuration and error disappear but I have another problem, after deploying first contract it remains stuck and keep counting confirmation block.

filip@filip-pc: yarn deploy
yarn run v1.22.4
$ truffle deploy -f 2 --to 2 --network ropsten --skip-dry-run --verbose-rpc --reset --describe-json

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

MIGRATION_STATUS:{"status":"preAllMigrations","data":{"dryRun":false,"migrations":[{"file":"/home/filip/Work/certME/certME-SmartContracts/migrations/2_deploy_smart_contracts.js","number":2,"isFirst":true,"isLast":true,"dryRun":false,"interactive":false}]}}

Starting migrations...
======================
> Network name:    'ropsten'
> Network id:      3
> Block gas limit: 8000029 (0x7a121d)

MIGRATION_STATUS:{"status":"preMigrate","data":{"file":"2_deploy_smart_contracts.js","number":2,"isFirst":true,"network":"ropsten","networkId":3,"blockLimit":"0x7a121d"}}

2_deploy_smart_contracts.js
===========================
MIGRATION_STATUS:{"status":"replacing","data":{"contractName":"AttributeRegistry","priorAddress":"0xFA67665B37fce2D89d613Fc0B7B7Ca8eAD5ef87E"}}

   Replacing 'AttributeRegistry'
   -----------------------------
   > transaction hash:    0x50d14831c4ca9a9c0f9f8114c1d5f62bb9c238543b5d8100d3abed8a35dff0de
   ⠙ Blocks: 81           Seconds: 1084

@ziggahunhow
Copy link

I'm also getting the encountering the same error with migrations being stuck, did you find a way to solve this?

@FilipLaurentiu
Copy link
Author

No fix for this. It seems that problem is with truffle trufflesuite/truffle#3091 (comment)

I'm also getting the encountering the same error with migrations being stuck, did you find a way to solve this?

@PudyJapan
Copy link

No fix for this. It seems that problem is with truffle trufflesuite/truffle#3091 (comment)

I'm also getting the encountering the same error with migrations being stuck, did you find a way to solve this?

Hi @FilipLaurentiu

Did you find a way to use the new ledger with truffle migration?

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

No branches or pull requests

3 participants