Truffle migrate issue

通过truffle migrate部署合约的时候遇到下面的错误:

  192:truffleProject daisy$ truffle migrate
Using network 'development'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: authentication needed: password or unlock
    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. (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:67535:24)

我们看到错误提示:
Error: authentication needed: password or unlock
所我们需要unlock一个账户
命令:personal.listAccounts 可以显示已有的账户列表,我们从中选一个解锁即可。
如果当前已有账号是空,运行 personal.newAccount创建账号

> personal.newAccount('12345678')
// 参数为账号密码
INFO [08-24|23:48:14] New wallet appeared                      url=keystore:///Users/daisy/mychain… status=Locked
"0x544ea0a0b7cf0aba03a77d602d26eb3828f85c9b"
> personal.listAccounts
["0xd5659f10d3f52bb765703c97c6de1b0370000f51", "0x85d019bf41d5939c34c03ea3ed36236772a99567", "0x435299f6a0e40c9ea4760bc1a318f35e2d9b2d83", "0x26ee5c23871ed3412d958b893ace03eae6e172e7", "0x544ea0a0b7cf0aba03a77d602d26eb3828f85c9b"]

然后运行personal.unlockAccount('0x544ea0a0b7cf0aba03a77d602d26eb3828f85c9b', '12345678', 1000) 来解锁账号

  • 第一个参数为账号id;
  • 第二个参数为创建账号密码
  • 第三个参数为解锁账号的时间,即1000秒操作账号无需输入密码
    解锁完之后再执行truffle migrate即可成功

你可能感兴趣的:(Truffle migrate issue)