Ok, finally I added some code to unlock account on the fly. I do not want to store password in truffle.js
(but it is possible), so doing next things:
Changed 1_initial_migration.js
this way:
const Web3 = require('web3');
const TruffleConfig = require('../truffle');
var Migrations = artifacts.require("./Migrations.sol");
module.exports = function(deployer, network, addresses) {
const config = TruffleConfig.networks[network];
if (process.env.ACCOUNT_PASSWORD) {
const web3 = new Web3(new Web3.providers.HttpProvider('http://' + config.host + ':' + config.port));
console.log('>> Unlocking account ' + config.from);
web3.personal.unlockAccount(config.from, process.env.ACCOUNT_PASSWORD, 36000);
}
console.log('>> Deploying migration');
deployer.deploy(Migrations);
};
And instead of calling truffle deploy
I am running it like:
ACCOUNT_PASSWORD=MySup4P@ssw0rd truffle deploy
As you can see node url and port are taken from config, so it is possible to add password
fields there, then check in migration for "callability" i.e.:
...
password: function() { return process.env.ACCOUNT_PASSWORD }
...
-- same thing but password logic will be moved to truffle.js
const EthereumWallet = require('ethereumjs-wallet'); const jsonWallet = fs.readFileSync('<<path to UTC file>>'); const parsedWallet = JSON.parse(jsonWallet); const wallet = EthereumWallet.fromV3(parsedWallet, '<<YOUR_PASSWORD_GOES_HERE>>');