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

Default Truffle project gives 'Expected parameter 'from' not passed to function.' error after 'truffle migrate' command #548

Closed
linkas45 opened this issue Aug 29, 2017 · 22 comments · May be fixed by trufflesuite/truffle-init-default#3

Comments

@linkas45
Copy link

Issue

I want to create a default generated project working with Truffle. After running the commands truffle init, truffle compile and truffle migrate I got the error: Expected parameter 'from' not passed to function. The geth rpc is successfully running in the other window of Terminal so it's not a problem.

Expected Behavior

I expect Truffle to start deploying migrations for the default Truffle project.

Actual Results

Using network 'development'.

/usr/local/lib/node_modules/truffle/build/cli.bundled.js:23538
        throw new Error("Expected parameter '" + key + "' not passed to function.");
        ^

Error: Expected parameter 'from' not passed to function.
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:23538:15
    at Array.forEach (<anonymous>)
    at Object.options (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:23536:19)
    at Object.run (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:66868:12)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:88946:23
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:67033:9
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:66861:7
    at done (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:155469:5)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:155526:11
    at FSReqWrap.oncomplete (fs.js:153:5)

Environment

  • Operating System: macOS Sierra
  • Truffle version: 3.4.9
  • Ethereum client: Geth 1.6.7
  • node version: 8.3.0
  • npm version: 5.3.0
@86me
Copy link

86me commented Sep 6, 2017

I'm receiving the same error. Just trying to follow the truffle token tutorial.

╰ % truffle migrate                                                                        10:43 PM 1 ↵
Using network 'development'.

/usr/local/lib/node_modules/truffle/build/cli.bundled.js:23538
        throw new Error("Expected parameter '" + key + "' not passed to function.");
        ^

Error: Expected parameter 'from' not passed to function.
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:23538:15
    at Array.forEach (<anonymous>)
    at Object.options (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:23536:19)
    at Object.run (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:66868:12)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:88946:23
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:67033:9
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:66861:7
    at done (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:155469:5)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:155526:11
    at FSReqWrap.oncomplete (fs.js:153:5)

MacOS 10.11.1
Truffle v3.4.9 (core: 3.4.8)
geth 1.6.7-stable-ab5646c5
node: stable 8.4.0 (bottled), HEAD
npm 5.3.0

leopoldjoy pushed a commit to leopoldjoy/truffle-init-default that referenced this issue Sep 7, 2017
resolve `parameter 'from' not passed to function` error by adding default `from` parameter to `truffle.js`. fix: trufflesuite/truffle#548
@leopoldjoy
Copy link

@linkas45 @86me Adding a default from field to the truffle.js file solved this problem for me, see here. I created a pull request for the fix: trufflesuite/truffle-init-default#3.

@casidiablo
Copy link

This usually happens if the running node has no accounts. By default, it seems that truffle will try to deploy the contracts using the first account available, which can be manually forced using the from property in the config.

@leopoldjoy
Copy link

leopoldjoy commented Sep 7, 2017

@casidiablo Yes, I think you're right. The error Expected parameter 'from' not passed to function seems unclear to me since it doesn't express that the running node has no accounts. Once you specify the from field in truffle.js you get the slightly clearer error: Error: unknown account. Do you think the from field should have a default value?

@86me
Copy link

86me commented Sep 7, 2017

@casidiablo Adding a 'from' paramater to truffle.js got me past this error. Only to open up another issue

╰ % truffle migrate                                                                         1:30 PM 1 ↵
Using network 'development'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: unknown account
    at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:37295:16)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:224765:36
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:66971:11
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:208348:9
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:209773:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:67130:18)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:67420:12)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:67575:12)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:67535:24)
    at emitNone (events.js:110:20)

Not sure why it's saying unknown account, because I'm currently running a testnet with a custom genesis block and an open rpc port with the specified account. I know the account exists; this is the output from an attached console:

> eth.coinbase
"0x6498b84547e91c853a4ecf0254589d3464d2444c"
> eth.getBalance(eth.coinbase)
5000000000000300000

The unknown account error I'm getting know is odd, because before I created my private network, I was getting an "insufficient gas" error using the same account, on the live network.

Here is the output of truffle.js:

module.exports = {
  rpc: {
      host:"localhost",
      port:8545
  },
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*",
      from: "6498b84547e91c853a4ecf0254589d3464d2444c",
      gas: 18000000000
    }
  }
};

I've tried with and without the "0x" in front of the account number.

I will keep trying, and open up a different issue if I can't figure this out.

@casidiablo
Copy link

That sucks. Does it happen if you deploy against an official testnet? Rinkeby for example.

@86me
Copy link

86me commented Sep 7, 2017

@casidiablo Yes, it worked when deployed with geth --testnet --rpc. Just had to lower the gas threshhold. Not sure what the difference was, but I'll take it.

Thanks for your help.

@DeveloperUX
Copy link

@86me Can you post what your truffle.js ended up looking like? I'm running into the same issue, played around with gas and the address in from but to no avail.

I'm trying to use the ropsten testnet:

networks: {
    "ropsten": {
      host: "localhost", // Connect to geth on the specified
      port: 8545,
      from: "0xf5071a2d92135545eaedffba45df5d3e7adbcfee", // default address to use for any transaction Truffle makes during migrations
      network_id: 3,  // The Ropsten testnet
      gas: 4612388 // Gas limit used for deploys
    }
}

@86me
Copy link

86me commented Nov 11, 2017

@DeveloperUX This is my current truffle.js

module.exports = {
  rpc: {
      host:"localhost",
      port:8545
  },
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "1337",
      from: "0x572857f9a9a59bdef971394f256f657dc963f1f5",
      gasPrice: 100000000000,
      gas: 4712388
    },
    rinkeby: {
      host: "localhost",
      port: 8545,
      network_id: "4",
      gas: 4712388,
      gasPrice: 100000000000,
      from: "0x79a1b6fecfa9c954803d2b59773fadc39d063e64"
    }
  }
};

I would try removing the quotes around "ropsten".

@86me
Copy link

86me commented Nov 11, 2017

@DeveloperUX Another technique I've found helpful when getting unexpected "out of gas" error messages is to pass the properties through the constructor in deployer.deploy() in 2_deploy_contracts.js. Here's an example:

var MyContract = artifacts.require("./MyContract.sol");

module.exports = function(deployer) {
  ...
  deployer.deploy(MyContract, startTime, endTime, wallet, { gas: 4712388 });
};

@stefek99
Copy link

please update error message

Very often there are deprecation warning.

A lot of old tutorials are using old syntax.

throw new Error("Expected parameter '" + key + "' not passed to function.");

Error: Expected parameter 'from' not passed to function.

Google works well, this issue is the first result but still... Updating error message is an easy job that will save some time.

@shrugs
Copy link

shrugs commented Apr 17, 2018

for googlers: you may also have something else running on 8545 (like an ssh session) that truffle doesn't respond to correctly. this is the error that comes up in that case.

@holyxiaoxin
Copy link

@shrugs you're right, I had parity running on 8545!

@mjibril
Copy link

mjibril commented Aug 28, 2018

I still had the same issue despite doing as @86me suggested. It turned out I had previously created an account with

geth account new

and the account was not found.
If you are using the testnet network you need to create a different account with

geth --testnet account new

@stale
Copy link

stale bot commented Nov 8, 2018

Thank you for raising this issue! It has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you would like to keep this issue open, please respond with information about the current state of this problem.

@stale stale bot added the stale label Nov 8, 2018
@RobinJQ
Copy link

RobinJQ commented Nov 15, 2018

I have the same problem! What is the solution??

@stale
Copy link

stale bot commented Nov 15, 2018

Thanks for your response! This issue is no longer considered stale and someone from the Truffle team will try to respond as soon as they can.

@stale stale bot removed the stale label Nov 15, 2018
@gnidan
Copy link
Contributor

gnidan commented Jan 9, 2019

Does this problem still exist on Truffle v5? Thanks!

@marsrobertson
Copy link

marsrobertson commented Apr 30, 2019

#548 (comment)

that truffle doesn't respond to correctly

In truffle.js I had some things commented out. Uncommented, now using:

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*", // Match any network id
      gas: 6000000
    }
  }
};

Better usability, user experience, developer experience, please

EDIT: I've figured it out, got stuck searching for the error message. All I wanted was to debug individual test in Chrome inspector. New syntax in play:

node --inspect-brk ./node_modules/truffle/build/cli.bundled.js test test/test_to_debug.js

@CruzMolina
Copy link
Contributor

Hey @marsrobertson , if I'm following correctly, you're using a v4 version of Truffle, and locally using an incompatible version of web3? Trying to grok the context of the bug you're seeing.

@eggplantzzz
Copy link
Contributor

Looks like this is not a thing any more. Closing this but please feel free to comment if I made a mistake! Thanks!

lucribas added a commit to lucribas/nd1309-work-code that referenced this issue Aug 25, 2020
@sg552
Copy link

sg552 commented Jul 9, 2022

If using truffle, you should best always specify the --network option. e.g.

truffle migrate --f 9 --network=ganache

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

Successfully merging a pull request may close this issue.

16 participants