openzeppelin-test-environment icon indicating copy to clipboard operation
openzeppelin-test-environment copied to clipboard

Document how to spin up a REPL

Open frangio opened this issue 5 years ago • 3 comments

Truffle users are used to truffle console. It is also possible to get a REPL connected to Test Environment. We should add this to our documentation.

$ node
> const { contract } = require('@openzeppelin/test-environment')
> const ERC20 = contract.fromArtifacts('ERC20')

frangio avatar Feb 26 '20 19:02 frangio

Note that truffle console is more feature-rich than the Node REPL: it supports things like automatic awaiting of promises. But yes, it'd be nice to mention this.

nventuro avatar Mar 02 '20 20:03 nventuro

Automatic awaiting of promises is a bad idea IMO. We can suggest use with --experimental-repl-await to be able to use await in the REPL.

truffle console will still have more features, sure. For example, it automatically loads all artifacts. I'd say we're catering to different users who may appreciate the minimalism.

frangio avatar Mar 02 '20 21:03 frangio

Note that you can already do this:

https://forum.openzeppelin.com/t/using-openzeppelin-sdk-from-node-typescript-prompt/2716/2

My recommendation is that add documentation guidance how to open the normal ts-node console (or node) console and import modules. Please do not add any automatic or hidden variables that pop out to the existing from nowhere - try to keep it so that the code runs same way regardless if it is a source code file or REPL prompt.

miohtama avatar Apr 27 '20 10:04 miohtama