I've trying to set up a dev environment for an ERC20 token. I configured my backend (NodeJS) and created a basic ERC20 token using Truffle and OpenZeppelin. Everything is fine, I was able to persist my contract into Rinkeby network. I already set up the Web3JS integration in my backend code (I'm using Infura) and I have the contract address in my hands. So now I want to interact with my contract via the backend.

My question is: How and what is the best way to interact with the contract?

I was able to interact with my Rinkeby contract using web3js a couple of day ago, but I had to paste the whole contract ABI into webpage (web3js instantiation). I don't believe it is the best way to interact with the contract and I didn't find any example of better way to do it.

Thanks in advance!

  • What exactly is the issue you are facing? Is it just a question of loading the ABI into a NodeJS script? What have you tried that didn't work? Commented Jul 31, 2018 at 17:57

1 Answer 1


In Web3.js, interacting with a contract requires the following:

  • The address of the contract
  • The contract ABI

All ERC20 compatible token contracts have the same baseline ABI, although some tokens may implement additional functions.

Note that you only need the parts of the ABI for the functions that you will be accessing, so even if a token contract adds additional functions, you should still be able to access its core ERC20 functions using the ERC20 standard ABI. This makes it really easy to write reusable code which allows you to access multiple contracts by only changing the initial address value.

You can learn a little more about this here.

View a minimal sample here with source code on GitHub.

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.