2

I'm trying to build a 'token generator' smart contract that accepts 3 arguments to then deploy a new token smart contract with those inputs ('strings' for symbol, name, 'address' for owner). I am a total novice, building from a basic escrow example (below), so any help is highly appreciated (!).

Reference: https://medium.com/coinmonks/creating-smart-contracts-with-smart-contract-d54e21d26e00

Example Solidity snippet for 'escrow generator' function:

enter image description here

So, basically instead of creating a new escrow contract that carries message value everytime someone calls it, I want to make a token generator that spits out an ERC20 with string and address inputs for symbol, name, owner.

Token snippet:

enter image description here

So, I am wondering what I can do to tweak the generator draft below to accept the these ^^ 3 arguments (_symbol, _name, _owner) that can customize new token smart contract for callers:

enter image description here

1

1 Answer 1

3

You can pass arguments through.

function newContract(string symbol, string name, ...) public ... {
  // must match the constructor inputs for the token implementation
  // assuming "contract ERC20Contract" is imported or visible to the compiler
  ERC20Contract tokenContract = new ERC20Contract(symbol, name, ...);
  contractAddresses.push(address(TokenContract));
  emit ...
  return ...
}

Hope it helps.

2
  • I believe this worked! Thank you very much for your attention and help here Feb 4, 2019 at 20:14
  • 1
    Thanks for voting and accepting. Vote hard. Vote often. The StackOverlords track that metric so it helps keep this site alive. :-) Feb 4, 2019 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.