2

Is it common to run external scripts with truffle? I keep seeing posts online with long js scripts to interact with contracts, but had no clue how people were running them outside of the console, which only accepts one-liners.

Anyway, I used the documentation to find out that my external script can be executed like this

truffle exec ./scripts/script.js

However, I'm getting an error that HodlEthereum is not defined when I try to run it.
The documentation states that I must use the module.exports encapsulation of my script. I've pasted what I have below:

module.exports = function(callback) {
    console.log(HodlEthereum.at("0x82d50ad3c1091866e258fd0f1a7cc9674609d254"));
}
1

Assuming that HodlEthereum is a contract that is part of your truffle project, try adding this to the top of your script:

const HodlEthereum = artifacts.require('HodlEthereum');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.