Learning Openzeppelin

Did you install openzeppelin contracts?

https://docs.openzeppelin.com/contracts/4.x/

Carlos Z

i did

1 Like

try to remove ../node_modules/ from the path, usually the paths start at @open... which is the folder where all the standard contracts are located (all of your modules files are stored in nodes_modules).

Carlos Z


its still showing this


I right click and copied path and relative path of eth.sol file and put it in comments for reference.

Ok so I re-did the whole project and somehow it’s working now.

Thankyou

1 Like

Thanks for the info in this post! I could compile, but couldn’t migrate, and this fixed the issue.
:+1:

Hi @JohnVersus,
When I deploy the ERC20 contract (MyToken) it doesn’t return functions. ((I followed the steps after Filip one by one))

Hi @Ahmad_Abd_Allah
In the previous command did you assign await MyToken.deployed() to instance ?
The command as per the tutorial is like this

// 1st command to define instance
let instance = await MyToken.deployed()

// 2nd command to log the instance
console.log(instance) 

// 3rd command is to run decimals function
instance.decimals()

In case if you did not assign await MyToken.deployed() to instance in the first command, 3rd command will throw an error.

Can you confirm if this is the case?

Hi @JohnVersus

Yeh, I assigned await MyToken.deployed() to instance.

Then followed the 2nd & 3rd command

@JohnVersus I still have the same issue

@JohnVersus

When I try to check balanceOf(accounts[0]) shows this

Hi @Ahmad_Abd_Allah

Can you share which version of @openzeppelin/contracts is installed in your project? Maybe I can check if something is different in your version.
I am currently testing with @openzeppelin/contracts version ^4.9.2 and the same steps seem to work.
When you run console.log(instance) you can see which callable functions are present in the contract. decimals functions should also be available in the list to call it.

That is is the expected result for balanceOf(accounts[0]). The balance is returned in Big Number format.

Hi @JohnVersus,

For the functions (decimals, symbol,…) it’s ok now, but for the balance function not in BN

the version installed:

@JohnVersus,

I guess those results of the decimals function because in ERC20 contract the decimals function in empty, am I correct??

Function:

Console:

I have created a new file with different name, but I still have the same issus

The balance which you shared in the previous image is in BN format only. For example here is how the balance of 20000 looks on my end.


I did not understand what you mean by empty here. As per the function code it returns value 18 of uint8 data type, hence when you run .decimal() function it returns the 18 in Big Number format.

@JohnVersus

I don’t why it doesn’t show the decimals or the balance functions as it should be (BN as in Filip’s session)??

It might be an issue with visual studio code version??

Ahh I see, In Filip’s video instance.decimals() returns < BN: 12 > but when we run the same command we see BN { negative: 0, words: [ 18, <1 empty item> ], length: 1, red: null }

If that is the consern, there is nothing wrong with the format which we are seeing now. The reason why it is like this could be due to the latest the truffle version. They might have updated how they show the Big Number. Previously it was returned as a string now it seems to return as objects.

Nevertheless, there is no error i\on how you are trying to do it.