hey @filip i am not getting this etherium part course so what will you recommand me about this
Hey @Ali_Ameen, hope you are well.
Maybe you should just use the ERC20
, if you are using the latest version of openzepelling (4.x), their new ERC20
contains the methods from the old ERC20Detailed
, you can read more about it here:
https://docs.openzeppelin.com/contracts/4.x/erc20
Carlos Z
hey @Ali_Ameen. I sugest you read the link that carlos provided. The lateest version of openzeppelin has bundled the ERC20Detailed into the main ECR20 contract so you dont need to reference it. However if you are still stuck scroll up a bit i have done an updated guide in each fourm section for this course explaining all of the updated steps one needs to take in order to finish the course. My original method was to install the older version of openzeppelin just so i coulf follow along with filip. But i would recommend using the latest version. If you complete soldity 201 first you will understand openzeppelin better. However for your isssue look at my post in this forum. It explains how to solve your issue. Creating our Token Discussion
At a complete loss here, for some reason my 2nd migration simply wont deploy I have no idea why but I belive it has something to do with how philip is using the old versions in the video. has anyone else had similar issues? why is it that if I change my compiler version in truffle config it dose absolutley nothing for the contract? im trying to switch to an older version to see if it helps
// Configure your compilers
compilers: {
solc: {
version: "0.5.0", // Fetch exact version from solc-bin (default: truffle's version)
// docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
I save it and it still gives me an error saying saying current compiler version is 0.8.7
Why is it that philip is using const in his migration instead of variable
what does th error message say post a screenshot. try usuing sol 0.8 or somethung.
Hello everyone I get this Compilation error
I guess I make a mistake in the constructor ?
Can someone get some hints please ?
token.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
import '../node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol';
contract GameToken is ERC20 {
constructor () ERC20(string memory name_, string memory symbol_) {
_mint(msg.sender, 10000);
}
}
with :
2_token_migration.js
const GameToken = artifacts.require("GameToken");
module.exports = function (deployer) {
deployer.deploy(GameToken,"GameTK","GTK");
};
I get this error msg below :
ParserError: Expected ‘,’ but got ‘memory’
–> project:/contracts/token.sol:7:33:
|
7 | constructor () ERC20(string memory name_, string memory symbol_) {
| ^^^^^^
Compilation failed. See above.
- Fetching solc version list from solc-bin. Attempt #1
- Fetching solc version list from solc-bin. Attempt #1
Compilation is all Ok if I use
constructor () ERC20(“GameTK”,“GTK”) {
and
deployer.deploy(GameToken);
Hi,
Could anybody please help me solving this error?
I am at Deploying our Token
section. I successfully run truffle develop
, but when trying to compile, receive the error: TypeError: Error parsing C:/Users/Olga/SimpleGame/Solidity/contracts/GameToken.sol: Cannot read properties of undefined (reading 'addFunction')
hey @mcgrane5 thank you for such a fast reply
here is what I wrote in the file:
pragma solidity 0.5.0
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";
contract GameToken is ERC20, ERC20Detailed {
constructor (string memory _name, string memory _symbol, uint8 _decimals)
ERC20Detailed (_name, _symbol, _decimals)
public
{}
function mint(address to, uint256 value) public returns (bool) {
_mint(to, value);
return true;
}
}
Hey @OlgaB, hope you are well.
Please share your code in the following way so we can review it properly
Carlos Z
Maybe useful for anyone taking the course in 2021 and in the future, and haven’t took the Ethereum Smart Contract Programming 201 course (which used a newer version of Openzeppelin) before this one.
-
You can use Visual Studio Code as an editor instead of Atom (depends on your preference), you have to download the Solidity plugin
-
use ‘npm install @openzeppelin/contracts’ to install the latest version of Openzeppellin
-
Here’s the code I used for the contract, stuff in ‘ERC20Detailed.sol’ mentioned in the video lecture is already included in ‘ERC20.sol’ if you ran the npm command mentioned above:
pragma solidity ^0.8.0;
import "../node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract GameToken is ERC20 {
constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) public {}
function mint(address to, uint256 amount) public virtual {
_mint(to, amount);
}
}
hey Olga. Yes i think your problem isyour using new openzeppelin librsary but the one from the video is older erc20Detailed is depricated. just remove the import
@mcgrane5 Thank you for help
Removing the import was only the first step - because I still received errors.
Took a look at what other folks of the academy are doing and I also renewed the versions.
Ran npm install @ openzeppelin /contracts AND ```
npm install -g truffle
Now it works!
brillant hats great to hear all the best with the rest of the course. be sure to post if you run into any issues
I hope you can help me as I am stuck.
If I work with openzeppelin 2.5.0 my Tokens do not mint and the mint call returns “true”
really dont understand why it wouldn’t mint.
same happens if I install the newest Version
After reading mcgrane5’s tipps I’ve switched to version 2.3 but now I can not compile as the file Context.sol is missing.
@Konzaih can you share the code. I would recommend going back to version 2.4 or whatever your previous version was so you dont have to ad the context file. can you share your code. its been ages since ive done this course so share your git repo and ill have a look
Hello @mcgrane5 yeah just wanted to add it after switching to another version, but you’re quick
currently I am on v2.1.1 as Filip in his video. Again the “True” result when trying to mint.
Github: https://github.com/EdiBes/EthereumJS_Game.git
GameToken.sol
pragma solidity ^0.5.0;
import "/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "/openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";
contract GameToken is ERC20, ERC20Detailed {
constructor(string memory _name, string memory _symbol, uint8 _decimals)
ERC20Detailed(_name, _symbol, _decimals)
public
{}
function mint(address account, uint256 value) public returns (bool) {
_mint(account, value);
return true;
}
}
ERC20.sol Mint function
function _mint(address account, uint256 value) internal {
require(account != address(0));
_totalSupply = _totalSupply.add(value);
_balances[account] = _balances[account].add(value);
emit Transfer(address(0), account, value);
}
Thanks for your help!
before i try to clone what is the error you get when you try to call the mint function