1

I'm developing with Truffle and Ganache

I have an standard ERC20 ABI that I import in my test file. it only has 3 optionals functions name, symbol and decimals.

const Token = artifacts.require('./Token')

And I instantiate it

token = await Token.new()

After this I can call it's functions directly like this

token.name()

How would I proceed to use the same functions on another ERC20 standard contract? Can I use my contract ABI that is pretty much standard or do I need another contract that will take a contract address as an argument to make the call to the right contract?

1 Answer 1

1

You can use:

  • token = await Token.new('name', 'symbol', decimals) in order to deploy and interact with a new Token instance
  • token = await Token.at('0xSomeAddress') in order to interact with an already-deployed Token instance

Depending on your Truffle version, the await before the at may be redundant.

But you can leave it there in order to stay on the safe side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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