1

I have a FactoryToken Contract Deployed and its function "newToken" Creates a new token contract. Every thing is working fine on Remix IDE but when i call the FactoryToken's function To create new token contract from Web GUI using TestRpc then it creates a new Contract But when i Add that address into the metamask account section ==> Add Token there it shows nothing. No information about the created token.

Code is working fine with Remix IDE on Ropsten Test Net but not with the TestRpc Accounts.

Below is the Factory Contract:

pragma solidity ^0.4.18;

import "./TestToken.sol";


contract FactoryToken {

  // index of created contracts

  address[] public contracts;

   mapping (address => bool) created;
  //Crowdsale public theObj;
  address newContract;


  string public  name ;
  string public  symbol ;
  uint256 public  decimals ;

  // useful to know the row count in contracts index

  function getContractCount() public constant returns(uint contractCount)
  {
    return contracts.length;
  }



   function getToken() public constant returns (string,string, uint256) {
       return (name, symbol,decimals);
   }


  // deploy a new contract

 function newToken(string _name, string _symbol, uint _decimals) public returns(address objAddress){


    newContract = new WILDToken(_name,_symbol,_decimals);

    contracts.push(newContract);

    return newContract;
}

   function verify() public constant returns (address) {
        return newContract;
    }
  //function GetAddress() public view returns (address) {

   // return (c);
  //}
}

In the function newToken, I am creating a New contract for Wild Token with the parameters Name, Symbol and Decimals

 function newToken(string _name, string _symbol, uint _decimals) public returns(address objAddress){


        newContract = new WILDToken(_name,_symbol,_decimals);

        contracts.push(newContract);

        return newContract;
    }

In my Html page with Web3 and TestRpc, I am Using the following code to create a New Token Contract

 $("#create").click(function () {


            Coursetro.newToken("My New Token", "MNT",18, { from: web3.eth.accounts[0], gas: '1000000' });



        });
  • I'm having the same issue, did you find a work around? – Karen S Mar 15 '18 at 16:42
  • Hi @karen, I am still at the same point but I have realised that the factory contract is generating the token contract and the generated tokens are then allocated to the factory contract no to the token contract due to which the actual token contract becomes empty and not showing the tokens. – usman mehmood Mar 16 '18 at 13:03

Your Answer

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

Browse other questions tagged or ask your own question.