解决我的部署问题的好方法是什么:(推进问题:松露测试问题,迁移成功,测试耗尽气体,加上测试文件。)
当我添加TestProcessApplicants.sol文件时,汽油用完了。我怀疑这也是正确的,因为在实体测试中实例化了本地实例来测试一些修饰符。
模块TransactionCost CredentialOrgFactory 2209646 CredentialFactory 1934056 SafeMath32 74748 ApplicantFactory 2432336 ProcessApplicants 1937776总计8588562
我怀疑需要一个3_deploy_contracts.js文件。我需要能够在下面的部署中设置引用地址,但我需要能够看到以前的(2_deploy_contracts.js)实例。我该怎么做?还是有更好的方法?或者我只是“做错了”。LOL。
这是2_deploy_contracts.js
var SafeMath32 = artifacts.require("./SafeMath32.sol");
var CredentialOrgFactory = artifacts.require("CredentialOrgFactory");
var CredentialFactory = artifacts.require("CredentialFactory");
var ApplicantFactory = artifacts.require("ApplicantFactory");
var ProcessApplicants = artifacts.require("ProcessApplicants");
module.exports = async function(deployer, accounts) {
let safeMathInst, aInst, bInst, cInst, dInst;
await Promise.all([
deployer.deploy(SafeMath32),
deployer.deploy(CredentialOrgFactory),
deployer.deploy(CredentialFactory),
deployer.deploy(ApplicantFactory),
deployer.deploy(ProcessApplicants),
deployer.link(SafeMath32, [CredentialOrgFactory,CredentialFactory,ApplicantFactory])
]);
instances = await Promise.all([
SafeMath32.deployed(),
CredentialOrgFactory.deployed(),
CredentialFactory.deployed(),
ApplicantFactory.deployed(),
ProcessApplicants.deployed(),
])
aInst = instances[1];
bInst = instances[2];
cInst = instances[3];
dInst = instances[4];
results = await Promise.all([
// Set Address of bInst so it can point at aInst
console.log("setAddress CredentialFactory: for CredentialOrgFactory"),
bInst.setAddress(aInst.address),
// Set Address of cInst so it can point at aInst
cInst.setAddress(aInst.address),
// Set Address of dInst so it can point at aInst, bInst, and cInst
dInst.setAddress(aInst.address, bInst.address, cInst.address)
]);
};发布于 2018-08-20 07:49:35
另一种解决特弗斯移民问题的办法:
Add web3 v1到您的 package.json文件:
"devDependencies": {
"web3": "1.0.0-beta.34",
...
}Create帮助文件 util.js**:**
let fs = require("fs");
let Web3 = require("web3");
let web3 = new Web3(NODE_ADDRESS);
async function send(transaction, gasMul = 1, gasAdd = 0) {
let gas = await transaction.estimateGas({from: PUBLIC_KEY});
let options = {
to : transaction._parent._address,
data: transaction.encodeABI(),
gas : gas * gasMul + gasAdd
};
let signedTransaction = await web3.eth.accounts.signTransaction(options, PRIVATE_KEY);
return await web3.eth.sendSignedTransaction(signedTransaction.rawTransaction);
}
async function deploy(contractName, contractArgs) {
let abi = fs.readFileSync(contractName + ".abi").toString();
let bin = fs.readFileSync(contractName + ".bin").toString();
let contract = new web3.eth.Contract(JSON.parse(abi));
let handle = await send(contract.deploy({data: "0x" + bin, arguments: contractArgs}));
console.log(`${contractName} contract deployed at address ${handle.contractAddress}`);
return new web3.eth.Contract(JSON.parse(abi), handle.contractAddress);
}
function deployed(contractName, contractAddr) {
let abi = fs.readFileSync(contractName + ".abi").toString();
return new web3.eth.Contract(JSON.parse(abi), contractAddr);
}使用In您的部署脚本,如下所示:
文件2_deploy_contracts.js:
let util = require("./util.js");
...
async function run() {
let myContract = await util.deploy("MyContract", [arg1, arg2, arg3]);
// Do asynchronous stuff with myContract...
}
...
run();文件3_deploy_contracts.js:
let util = require("./util.js");
...
async function run() {
let myContract = util.deployed("MyContract");
// Do asynchronous stuff with myContract...
}
...
run();使用NodeJS: Execute这些部署脚本
node 2_deploy_contracts.js
node 3_deploy_contracts.js<#>I建议从命令行传递系统配置,即:
在每个部署脚本中,添加以下内容:
let NODE_ADDRESS = process.argv[2];
let PUBLIC_KEY = process.argv[3];
let PRIVATE_KEY = process.argv[4];然后将这些值传递给util模块。
https://ethereum.stackexchange.com/questions/56910
复制相似问题