I'm trying to deploy a contract to the ropsten testnet using truffle, but I get the following error:
Deploying 'Migrations'
   ----------------------
Error:  *** Deployment Failed ***
"Migrations" -- invalid sender.
    at /home/usr/.npm/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
    at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.2.5 (core: 5.2.5)
Node v10.19.0
When deploying to ganache locally, it works fine. Also I'm pretty sure my truffle-config.js is correct, it's the same as all the online tutorials, but since I'm here, I guess I'm not completely sure :). The address that hd-wallet is using is also correct (verified with the console.log statement in truffle-config.js) and it has 5 ETH balance, so more than enough. I have 2 migration scripts, it gives exactly the same error with each script.
truffle-config.js:
require("dotenv").config();
const HDWalletProvider = require("@truffle/hdwallet-provider");
module.exports = {
    networks: {
        ropsten: {
            provider: () => {
                var provider = new HDWalletProvider({
                    mnemonic: process.env.MNEMONIC,
                    providerOrUrl: `https://ropsten.infura.io/v3/${process.env.INFURA_KEY}`,
                    derivationPath: "m/44'/60'/0'/0/",
                    addressIndex: 0,
                });
                console.log(provider.getAddress());
                return provider;
            },
            network_id: 3,
            gas: 5500000,
            confirmations: 2,
            timeoutBlocks: 200,
            skipDryRun: true,
        },
        development: {
            host: "127.0.0.1",
            port: 7545,
            network_id: "*",
        },
    },
    compilers: {
        solc: {
            version: "0.6.0",
            optimizer: {
                enabled: true,
                runs: 200,
            },
        },
    },
};
1_initial_migration.js:
const Migrations = artifacts.require("Migrations");
module.exports = function (deployer) {
  deployer.deploy(Migrations);
};
2_deploy.js:
const Token = artifacts.require("Token");
module.exports = (deployer) => {
    deployer.deploy(Token);
};
Token.sol:
//SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract Token is ERC20 {
    address minter;
    // minterChanged event
    event minterChanged(address indexed from, address to);
    
    constructor() public payable ERC20("Decentralized Bank Currency", "DCB") {
        minter = msg.sender;
    }
    function transferMinterRole(address bank) public returns(bool) {
        require(msg.sender == minter);
        minter = bank;
        emit minterChanged(msg.sender, minter);
        return true;
    }
    function mint(address account, uint256 amount) public {
        require(msg.sender == minter);
        _mint(account, amount);
    }
}
Escrow.sol:
//SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0 ;
contract Escrow {
    address agent;
    mapping(address => uint256) public deposits;
    modifier onlyAgent() {
        require(msg.sender == agent);
        _; // return void
    }
    constructor() public {
        // solidity heeft globale var msg
        agent = msg.sender;
    }
    function deposit(address payee) payable public onlyAgent {
        uint256 amount = msg.value;
        deposits[payee] = deposits[payee] + amount;
    }
    function withdras(address payable payee) public onlyAgent {
        uint256 payment = deposits[payee];
        deposits[payee] = 0;
        payee.transfer(payment);
    }
}
Try a different version @truffle/hdwallet-provider Works for me with 1.2.3
npm uninstall @truffle/hdwallet-provider npm install @truffle/[email protected]
With the latest version (1.2.4) there was the same error (invalid sender).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With