Hey - I'm having trouble using truffle flatten. It's throwing error
/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol for extracting its imports: ParserError: missing ';' at '{' (158:18) NOTE: Please make sure to run npm install in the truffle project dir.
Here's the contract I'm trying to flatten.
// contracts/Test.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/ownable.sol";
contract Test is ERC20, Ownable {
address public admin;
constructor() ERC20("Testcoin", "TST") {
_mint(msg.sender, 100000000000 * 10 ** 18);
admin = msg.sender;
}
function burn(uint amount) private {
require(msg.sender == admin, 'only admin');
_burn(msg.sender, amount);
}
}
I know there are other articles that explain other ways of doing this and getting verification. But I really wanted to flatten all the code for my website and also to test some of the functions in Remix
Hi, could you please show your file named package.json?
And if you want to test your code on the remix, I think there is no need to flatten the whole contracts, cause remix has support the OpenZeppelin repo, you can copy the code you show above and then paste to the remix to have a test.
So I had to run npm init -y in my root folder to create a package.json file. Apparently, truffle doesn't create one automaticaly. Tried to run the flattener again and still no luck.