Following Create an ERC20 using Truffle tutorial but nothing works after copying artifacts

Hello All.
from Australia. i am a bit stuck on the below. Create an ERC20 using Truffle, without writing Solidity

The Preset contracts have already been compiled, so we only need to copy the artifacts to the build/contracts directory.

$ mkdir -p build/contracts/
$ cp node_modules/@openzeppelin/contracts/build/contracts/* build/contracts/

i have the folder their and yet i when i paste the second line of text in to my terminal nothing works.

`
1 Like

Hi @Triston_Edwards,

Welcome to the community :wave:

I am in Melbourne Australia :australia: (where we are in lockdown and it is raining :smile:).

When you say nothing works, what actually happens?

What operating system and version of node, npm are you using?

I am using WSL2 on Windows 10 (Ubuntu 18.04) using node 10.

$ npx truffle version
Truffle v5.1.47 (core: 5.1.47)
Solidity v0.5.16 (solc-js)
Node v10.22.1
Web3.js v1.2.1

I did the following using the steps from the tutorial (apart from the directory name) and was able to interact with the token.

abcoathup@OpenZeppelin:~/projects/forum$ mkdir triston
abcoathup@OpenZeppelin:~/projects/forum$ cd triston
abcoathup@OpenZeppelin:~/projects/forum/triston$ npm init -y
Wrote to /home/abcoathup/projects/forum/triston/package.json:

{
  "name": "triston",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}


abcoathup@OpenZeppelin:~/projects/forum/triston$ npm i --save-dev @openzeppelin/contracts
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN triston@1.0.0 No description
npm WARN triston@1.0.0 No repository field.

+ @openzeppelin/contracts@3.2.0
added 1 package from 1 contributor and audited 1 package in 3.587s
found 0 vulnerabilities

abcoathup@OpenZeppelin:~/projects/forum/triston$ npm i truffle
npm WARN deprecated flat@4.1.0: Fixed a prototype pollution security issue in 4.1.0, please upgrade to ^4.1.1 or ^5.0.1.

> truffle@5.1.47 postinstall /home/abcoathup/projects/forum/triston/node_modules/truffle
> node ./scripts/postinstall.js

- Fetching solc version list from solc-bin. Attempt #1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN triston@1.0.0 No description
npm WARN triston@1.0.0 No repository field.

+ truffle@5.1.47
added 138 packages from 62 contributors and audited 139 packages in 22.406s

31 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

abcoathup@OpenZeppelin:~/projects/forum/triston$ npx truffle init

Starting init...
================

> Copying project files to /home/abcoathup/projects/forum/triston

Init successful, sweet!

abcoathup@OpenZeppelin:~/projects/forum/triston$ mkdir -p build/contracts/
abcoathup@OpenZeppelin:~/projects/forum/triston$ cp node_modules/@openzeppelin/contracts/build/contracts/* build/contracts/
abcoathup@OpenZeppelin:~/projects/forum/triston$ npx truffle develop
Truffle Develop started at http://127.0.0.1:9545/

Accounts:
(0) 0x0445c33bdce670d57189158b88c0034b579f37ce
(1) 0x46b68a577f95d02d2732cbe93c1809e9ca25b443
(2) 0xff8ddfd4ae8ed56c4b94738fef931b732f3aaeb5
(3) 0xc28aaeb2c63c3617e6733d786a6d7273871b805f
(4) 0xab36c13ac120075f84f0cffc17f30ec22c6abf39
(5) 0x95d6b12b0681c43c269738f6dfc854b2f0e5b413
(6) 0x5f6522939e0e5ffeae31015d547e7e06f70be492
(7) 0xcf501b78c509f5b5726de358955c3b42507feebb
(8) 0x236ae33001d49014212d14260715f4a4fe41402f
(9) 0x294021281f336480fca886e238cb96449a211b6a

Private Keys:
(0) 11e8321617611610d7561dfdf1fdbf87cee4cc99b97cc73c68f0eb5715fff7cc
(1) b28ee7deb262fbb6cccabb43179406e97bf7ff4c20b66feac3321019373531bd
(2) 44e5ce1f204a63e50faf2f202af1d5653aace83805dd9bc7062033f0625aaaa7
(3) 168e28ad21ede684f8fd3ddc8b88e9474c740884f43bda1d567e968544b53a6e
(4) 1a19f312af61a4f982c5f10e9321d2ca38827dc6a1685c13138579bfe221d8f2
(5) c6345c61bf7460b52816100238f87f28e2864503f49cad57aecd5e189426d6b1
(6) 4412060a796a8f1b3c722d68771c01159283961e055879f93ef01024bdd8fdc0
(7) da6e2922a627bb7313156121e3b090609298eb9d76754d3e233912de5a735b04
(8) 8a1694b08e7631d94c906d93e8d00df37a4cc42ec16388b29aaaee6cd645f754
(9) 6d138e6e5b3b78b6ad6bc619fa8d417cfc0233d5d1e1a250688d1c38289a13cf

Mnemonic: ridge drop soon clutch empty north car drum maximum obey clinic coin

⚠️  Important ⚠️  : This mnemonic was created for you by Truffle. It is not secure.
Ensure you do not use it on production blockchains, or else you risk losing funds.

truffle(develop)> token = await ERC20PresetMinterPauser.new("My Token", "TKN")
undefined
truffle(develop)> await token.name()
'My Token'

hi @abcoathup

I am based on the sunshine coast. sorry to say but its a real nice day today.
thank you for taking the time to help me. i am really not getting this. would there be anyway i could do a screen share or a phone call?.

I am on windows 10 with the latest node install. I have ganache connected. i just dont get how to move on from this point and i feel like i am close.

1 Like

Hi @Triston_Edwards,

Enjoy the sunshine and the freedom. It is still raining outside here. :cloud_with_rain:

What version of node are you using? I recommend using node 10 or node 12.
To benefit the entire community support is done via the forum. We don’t currently do community calls (yet).

Can you share the output of npx truffle version?

When you said nothing works, what happens? Can you share the output or a screenshot.

If you get stuck, you can try using Remix (web based) just so that you can start playing around with a token: Create an ERC20 using Remix, without writing Solidity

i have made a video of where i get stuck. taking in mind that i am wanting to use my ganache account.
as you see i get stuck on the next parts.

1 Like

Hi @Triston_Edwards,

Awesome. Thanks for the video. That was really helpful to see where I can improve the tutorial.

The tutorial uses a precompiled contract (so we don’t have to write any Solidity to get started), so we are just copying the artifacts to our projects build directory and can then deploy.

The first step creates the build directory. The second step copies the artifacts.

$ mkdir -p build/contracts/
$ cp node_modules/@openzeppelin/contracts/build/contracts/* build/contracts/

The following used to be the output of npx truffle init. I can see from your video how this could be confusing.

$ npx truffle init
This directory is non-empty...
? Proceed anyway? (Y/n)
Starting unbox...
=================

? Proceed anyway? Yes
âś” Preparing to download box
âś” Downloading
âś” cleaning up temporary files
âś” Setting up box

Unbox successful, sweet!

Commands:

  Compile:        truffle compile
  Migrate:        truffle migrate
  Test contracts: truffle test

ok as you can see i cut and pasted
$ mkdir -p build/contracts/
$ cp node_modules/@openzeppelin/contracts/build/contracts/* build/contracts/

Now i have some files in that folder but my token Has no name or info how do i do this as right now it saying 0 passing (0ms).

Compiling your contracts...

Everything is up to date, there is nothing to compile.

0 passing (0ms)

1 Like

Hi @Triston_Edwards,

You don’t have any tests (we don’t cover that in the tutorial), so npx truffle test doesn’t test anything.
You don’t have any migration scripts (apart from the default), so npx truffle migrate only deploys Truffle’s Migration.sol. You can add a migration script to deploy the token (at the end of the tutorial).

Once you have copied the artifacts you can then deploy the token.

If you go back to the tutorial you can run:

npx truffle develop

Then you can create a new token specifying the name and symbol

truffle(develop)> token = await ERC20PresetMinterPauser.new("My Token", "TKN")
undefined

We can call the contract to read token metadata such as name , symbol and decimals

truffle(develop)> await token.name()
'My Token'
truffle(develop)> await token.symbol()
'TKN'
truffle(develop)> (await token.decimals()).toString()
'18'

You can follow the tutorial for minting and burning.


Once you have done the above, you can deploy to a local network (such as Ganache GUI).

You would need to create a migration script that will be run when you use npx truffle migrate

sorry i dont know what what or how you mean by:
Once you have copied the artifacts you can then deploy the token.

I tried pasting this in terminal
truffle(develop)> token = await ERC20PresetMinterPauser.new(“My Token”, “TKN”)
undefined… and it didnt work.

also if i use npx truffle develop its not in my Ganache as it is now giving new Truffle Develop started at http://127.0.0.1:9545/ and thats not my ganache ?

what artifacts ? i cant see what you mean can you do a Video ? as to me (noobish) i cant understand this part.

i jumped to these commands
await token.name
await token.symbol
and it tells me My Token", “TKN” i am super confused over this and i know i shouldn’t be.

1 Like

Hi @Triston_Edwards,

I made an asciinema of me going through all the steps in the tutorial:
https://asciinema.org/a/364291

Once you have that working you can then update your truffle-config.js to create a network configuration to use Ganache GUI and a migration script to deploy the token.

yikes whats all this about. IF THE TOKEN IS IN A PAUSED STATE. how do you call the Unpaused transaction ?
}

truffle(develop)> await token.pause()
Uncaught:
Error: Returned error: VM Exception while processing transaction: revert Pausable: paused -- Reason given: Pausable: paused.
    at evalmachine.<anonymous>:1:15
    at evalmachine.<anonymous>:2:49
    at sigintHandlersWrap (vm.js:272:15)
    at Script.runInContext (vm.js:127:14)
    at runScript (C:\Users\jake\Documents\My Apps in NODE\Basic Site\Create an ERC20 using Truffle, without writing Solidity\mytoken\node_modules\truffle\build\webpack:\packages\core\lib\console.js:251:1)
    at Console.interpret (C:\Users\jake\Documents\My Apps in NODE\Basic Site\Create an ERC20 using Truffle, without writing Solidity\mytoken\node_modules\truffle\build\webpack:\packages\core\lib\console.js:266:1)
    at bound (domain.js:427:14)
    at REPLServer.runBound [as eval] (domain.js:440:12)
    at REPLServer.onLine (repl.js:760:10)
    at REPLServer.emit (events.js:315:20)
    at REPLServer.EventEmitter.emit (domain.js:483:12)
    at REPLServer.Interface._onLine (readline.js:329:10)
    at REPLServer.Interface._line (readline.js:658:8)
    at REPLServer.Interface._ttyWrite (readline.js:1003:14)
    at REPLServer.self._ttyWrite (repl.js:850:9)
    at ReadStream.onkeypress (readline.js:205:10)
    at ReadStream.emit (events.js:315:20)
    at ReadStream.EventEmitter.emit (domain.js:483:12)
    at emitKeys (internal/readline/utils.js:335:14)
    at emitKeys.next (<anonymous>)
    at ReadStream.onData (readline.js:1137:36)
    at ReadStream.emit (events.js:315:20)
    at ReadStream.EventEmitter.emit (domain.js:483:12)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at ReadStream.Readable.push (_stream_readable.js:212:10)
    at TTY.onStreamRead (internal/stream_base_commons.js:186:23)
    at TTY.callbackTrampoline (internal/async_hooks.js:120:14) {
  reason: 'Pausable: paused',
  hijackedStack: 'Error: Returned error: VM Exception while processing transaction: revert Pausable: paused -- Reason given: Pausable: paused.\n' +
1 Like

Hi @Triston_Edwards,

When you pause a token, the functionality is configured that no transfers can occur, though you can use other functions.

It looks like you already called pause when you called pause.

In the asciinema video, you can call await token.unpause() from an account with the Pauser role to return the token to an unpaused state.
https://asciinema.org/a/364291