0

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

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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