LimeChain / etherlime

Dapp Development framework based on ethers.js
MIT License
185 stars 41 forks source link

getting 0x bytecode with open zeppelin import #282

Closed MohamedLEGH closed 5 years ago

MohamedLEGH commented 5 years ago

This is my code :

pragma solidity ^0.5.0;

import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";

contract MAINToken is ERC20Detailed {
  string name_token = "MyToken";
  string symbol_token = "MAIN";
  uint8 decimal_number = 18;

  constructor() ERC20Detailed(name_token, symbol_token, decimal_number) public {

  }

}

When I run etherlime compile, the contract is compiled without error but the bytescode is "0x". Same with flatten file.

Any idea how to solve this?

MohamedLEGH commented 5 years ago

My bad, I forgot to add ERC20 import and call the mint function. This is the good code :

pragma solidity ^0.5.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";

contract MAINToken is ERC20, ERC20Detailed {
  string name_token = "MyToken";
  string symbol_token = "MAIN";
  uint8 decimal_number = 18;
  uint256 total_amount = 2000 * (10 ** uint256(decimal_number));

  constructor() ERC20Detailed(name_token, symbol_token, decimal_number) public {
        _mint(msg.sender, total_amount);
  }

}

With this code I get a bytecode and I can publish it on the blockchain.