0

I've been copying pasting some examples around and realized there is something I dont fully get. In my test.js code(that I execute via truffle test I can call await contract.getMintPrice() fine but in my front end JS code I call await contract.methods.getMintPrice().call() and I realized I don't really know why? Can someone help explain? Thanks.

1 Answer 1

0

Inside truffle tests contract are wrapped in a TruffleContract object. The wrapper allows calling methods like this:

await contract.getMintPrice()

When using web3.js contracts are wrapped in a web3.eth.Contract. It has a different syntax, and the same method should be called as

await contract.methods.getMintPrice().call()

They are two different packages each having its own syntax.

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.