报错:Error: Expected parameter 'from' not passed to function.
EVM/moonbeam_doc/Using with Truffle/TruffleTest/MetaCoin$ truffle migrateCompiling your contracts...===========================> Everything is up to date, there is nothing to compile.Error: Expected parameter 'from' not passed to function. at has (/usr/local/lib/node_modules/truffle/build/webpack:/packages/expect/dist/src/index.js:10:1) at Object.options (/usr/local/lib/node_modules/truffle/build/webpack:/packages/expect/dist/src/index.js:19:1) at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:65:1) at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:258:1) at processTicksAndRejections (internal/process/task_queues.js:93:5) at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:223:1) at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:172:1)Truffle v5.4.3 (core: 5.4.3)Node v14.15.5
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
解决:
在trufle-config.js中添加:from参数,软件定制开发供应商表示哪个账户在部署合约
添加前:
module.exports = { networks: { development: { host: "127.0.0.1", port: 9933, network_id: "*", } } };
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
添加后:
module.exports = { networks: { development: { host: "127.0.0.1", port: 9933, network_id: "*", from: "0x6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b", } } };
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
0x6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b
软件定制开发供应商是节点内置的以太坊账户。
再次部署:truffle migrate,报错:no signer available.
:
EVM/moonbeam_doc/Using with Truffle/TruffleTest/MetaCoin$ truffle migrateCompiling your contracts...===========================> Everything is up to date, there is nothing to compile.Starting migrations...======================> Network name: 'development'> Network id: 1281> Block gas limit: 15000000 (0xe4e1c0)1_initial_migration.js====================== Deploying 'Migrations' ----------------------Error: *** Deployment Failed ***"Migrations" -- Returned error: no signer available. at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1 at processTicksAndRejections (internal/process/task_queues.js:93:5) at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:70:1) at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:56:1) at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:217:1) at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1) at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1) at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:87:1) at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:258:1) at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:223:1) at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:172:1)Truffle v5.4.3 (core: 5.4.3)Node v14.15.5
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
查看账户
先进入truffle控制台:
truffle console
- 1
默认账户:
truffle migrate命令运行迁移脚本来部署合约。
执行truffle migrate
时使用的账户是哪个?
web3.eth.defaultAccount属性记录了默认地址,在以下方法中如果没有指定from
属性,将使用web3.eth.defaultAccount属性的值作为默认的from属性值。
- web3.eth.sendTransaction()
- web3.eth.call()
- new web3.eth.Contract() -> myContract.methods.myMethod().call()
- new web3.eth.Contract() -> myContract.methods.myMethod().send()
调用:
web3.eth.defaultAccount
- 1
属性:
String
– 20 Bytes: 以太坊地址,你应当在节点或keystore中存有该地址的私钥。默认值为undefined
示例代码:
web3.eth.defaultAccount;> undefined// set the default accountweb3.eth.defaultAccount = '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe';
- 1
- 2
- 3
- 4
- 5
ganache-cli预置了10个账户,truffle migrate默认使用预置第一个的账户进行部署合约。
相关内容: