Deploy new contract through another contract function in Truffle Planned maintenance scheduled...
Does classifying an integer as a discrete log require it be part of a multiplicative group?
What does this Jacques Hadamard quote mean?
What causes the direction of lightning flashes?
How could we fake a moon landing now?
How does the math work when buying airline miles?
First console to have temporary backward compatibility
If a VARCHAR(MAX) column is included in an index, is the entire value always stored in the index page(s)?
Is "Reachable Object" really an NP-complete problem?
Is this homebrew Lady of Pain warlock patron balanced?
Did MS DOS itself ever use blinking text?
What does the "x" in "x86" represent?
If my PI received research grants from a company to be able to pay my postdoc salary, did I have a potential conflict interest too?
How do I find out the mythology and history of my Fortress?
Fundamental Solution of the Pell Equation
Can an alien society believe that their star system is the universe?
How to find all the available tools in mac terminal?
How do I make this wiring inside cabinet safer? (Pic)
What is homebrew?
Dating a Former Employee
What would be the ideal power source for a cybernetic eye?
What's the meaning of "fortified infraction restraint"?
How to convince students of the implication truth values?
Would "destroying" Wurmcoil Engine prevent its tokens from being created?
Is there such thing as an Availability Group failover trigger?
Deploy new contract through another contract function in Truffle
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?How is the address of an Ethereum contract computed?Transaction receipt has contractAddress as null'Error: base fee exceeds gas limit' When creating new contract instance (Using Truffle, Web3Js and testrpc)Truffle migrate vs Truffle deployVM Exception: Contract from within a contractDeploying contracts in truffle while passing parameters of it constructor results in an errorTruffle Deploy Doesn't WorkTruffle deployment error with infuraTruffle contract migration deploying same contract on multiple addressTruffle deployment with metamask to ganache leads private key errorDeploying smart contract through TruffleReferenceError: address is not defined
I have a function in my contract minter.sol
that creates another contract etnX.sol
:
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
}
I want to call this function in truffle and get new contract address.
I'm trying to do so:
const minter = artifacts.require('../contracts/minter.sol')
const etnX = artifacts.require('etnX')
const etnXs = [100,200,500,1000,10000,100000,1000000,10000000]
module.exports = async function(deployer) {
deployer.deploy(minter).then(async() => {
var minterInstance = await minter.deployed();
for (var i=0; i<etnXs.length;i++)
await minterInstance.createNewContract("x","x", etnXs[i]);
var x = await etnX.deployed();
console.log(x.address);
})
};
However, it doesn't deploy. Can someone explain me how to do this?
truffle dapp-development testing truffle-migration truffle-deployment
add a comment |
I have a function in my contract minter.sol
that creates another contract etnX.sol
:
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
}
I want to call this function in truffle and get new contract address.
I'm trying to do so:
const minter = artifacts.require('../contracts/minter.sol')
const etnX = artifacts.require('etnX')
const etnXs = [100,200,500,1000,10000,100000,1000000,10000000]
module.exports = async function(deployer) {
deployer.deploy(minter).then(async() => {
var minterInstance = await minter.deployed();
for (var i=0; i<etnXs.length;i++)
await minterInstance.createNewContract("x","x", etnXs[i]);
var x = await etnX.deployed();
console.log(x.address);
})
};
However, it doesn't deploy. Can someone explain me how to do this?
truffle dapp-development testing truffle-migration truffle-deployment
add a comment |
I have a function in my contract minter.sol
that creates another contract etnX.sol
:
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
}
I want to call this function in truffle and get new contract address.
I'm trying to do so:
const minter = artifacts.require('../contracts/minter.sol')
const etnX = artifacts.require('etnX')
const etnXs = [100,200,500,1000,10000,100000,1000000,10000000]
module.exports = async function(deployer) {
deployer.deploy(minter).then(async() => {
var minterInstance = await minter.deployed();
for (var i=0; i<etnXs.length;i++)
await minterInstance.createNewContract("x","x", etnXs[i]);
var x = await etnX.deployed();
console.log(x.address);
})
};
However, it doesn't deploy. Can someone explain me how to do this?
truffle dapp-development testing truffle-migration truffle-deployment
I have a function in my contract minter.sol
that creates another contract etnX.sol
:
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
}
I want to call this function in truffle and get new contract address.
I'm trying to do so:
const minter = artifacts.require('../contracts/minter.sol')
const etnX = artifacts.require('etnX')
const etnXs = [100,200,500,1000,10000,100000,1000000,10000000]
module.exports = async function(deployer) {
deployer.deploy(minter).then(async() => {
var minterInstance = await minter.deployed();
for (var i=0; i<etnXs.length;i++)
await minterInstance.createNewContract("x","x", etnXs[i]);
var x = await etnX.deployed();
console.log(x.address);
})
};
However, it doesn't deploy. Can someone explain me how to do this?
truffle dapp-development testing truffle-migration truffle-deployment
truffle dapp-development testing truffle-migration truffle-deployment
asked 18 hours ago
AleksandrAleksandr
509
509
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
1.) You can make the function emit an event that broadcasts the new address and then check the logs of the transaction receipt. Receipt
// Solidity
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
emit NewContract(address(c));
}
// Javascript
let tx = await minterInstance.createNewContract("x", "x", 300);
// Look through tx.logs for event results
2.) You can return the contract address in the solidity function and then instead of initiating a transaction make a call() to get the address. (Then make the transaction....it will be deployed at the same address as returned by the call())
// Solidity
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner
returns (address) {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
return address(c)
}
// Javascript
let addr = await minterInstance.createNewContract.call("x", "x", 300);
3.) Manually calculate it
add a comment |
The Cryptocurenncy Very Special When Her Open : Mining Pool / Trading / Hot Wallet With : Ethereum Revolutions : We Target Last Price On The Decemner $120
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "642"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fethereum.stackexchange.com%2fquestions%2f69754%2fdeploy-new-contract-through-another-contract-function-in-truffle%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
1.) You can make the function emit an event that broadcasts the new address and then check the logs of the transaction receipt. Receipt
// Solidity
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
emit NewContract(address(c));
}
// Javascript
let tx = await minterInstance.createNewContract("x", "x", 300);
// Look through tx.logs for event results
2.) You can return the contract address in the solidity function and then instead of initiating a transaction make a call() to get the address. (Then make the transaction....it will be deployed at the same address as returned by the call())
// Solidity
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner
returns (address) {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
return address(c)
}
// Javascript
let addr = await minterInstance.createNewContract.call("x", "x", 300);
3.) Manually calculate it
add a comment |
1.) You can make the function emit an event that broadcasts the new address and then check the logs of the transaction receipt. Receipt
// Solidity
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
emit NewContract(address(c));
}
// Javascript
let tx = await minterInstance.createNewContract("x", "x", 300);
// Look through tx.logs for event results
2.) You can return the contract address in the solidity function and then instead of initiating a transaction make a call() to get the address. (Then make the transaction....it will be deployed at the same address as returned by the call())
// Solidity
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner
returns (address) {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
return address(c)
}
// Javascript
let addr = await minterInstance.createNewContract.call("x", "x", 300);
3.) Manually calculate it
add a comment |
1.) You can make the function emit an event that broadcasts the new address and then check the logs of the transaction receipt. Receipt
// Solidity
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
emit NewContract(address(c));
}
// Javascript
let tx = await minterInstance.createNewContract("x", "x", 300);
// Look through tx.logs for event results
2.) You can return the contract address in the solidity function and then instead of initiating a transaction make a call() to get the address. (Then make the transaction....it will be deployed at the same address as returned by the call())
// Solidity
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner
returns (address) {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
return address(c)
}
// Javascript
let addr = await minterInstance.createNewContract.call("x", "x", 300);
3.) Manually calculate it
1.) You can make the function emit an event that broadcasts the new address and then check the logs of the transaction receipt. Receipt
// Solidity
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
emit NewContract(address(c));
}
// Javascript
let tx = await minterInstance.createNewContract("x", "x", 300);
// Look through tx.logs for event results
2.) You can return the contract address in the solidity function and then instead of initiating a transaction make a call() to get the address. (Then make the transaction....it will be deployed at the same address as returned by the call())
// Solidity
function createNewContract(string memory name, string memory symbol, uint256 _maxSupply)
public onlyOwner
returns (address) {
etnX c = new etnX(name, symbol, _maxSupply, address(store));
return address(c)
}
// Javascript
let addr = await minterInstance.createNewContract.call("x", "x", 300);
3.) Manually calculate it
edited 14 hours ago
answered 16 hours ago
Kyle DewhurstKyle Dewhurst
513
513
add a comment |
add a comment |
The Cryptocurenncy Very Special When Her Open : Mining Pool / Trading / Hot Wallet With : Ethereum Revolutions : We Target Last Price On The Decemner $120
New contributor
add a comment |
The Cryptocurenncy Very Special When Her Open : Mining Pool / Trading / Hot Wallet With : Ethereum Revolutions : We Target Last Price On The Decemner $120
New contributor
add a comment |
The Cryptocurenncy Very Special When Her Open : Mining Pool / Trading / Hot Wallet With : Ethereum Revolutions : We Target Last Price On The Decemner $120
New contributor
The Cryptocurenncy Very Special When Her Open : Mining Pool / Trading / Hot Wallet With : Ethereum Revolutions : We Target Last Price On The Decemner $120
New contributor
New contributor
answered 1 hour ago
BIGCRYPTO001BIGCRYPTO001
11
11
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Ethereum Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fethereum.stackexchange.com%2fquestions%2f69754%2fdeploy-new-contract-through-another-contract-function-in-truffle%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown