I am using truffle-contract for connecting between frontend and smart contract. Currently, I can call method on smart contract and can consume ether successfully.
const result = await instance.adoptCreeptomas(
aquaQuantity,
firaQuantity,
aetherQuantity,
gaiaQuantity,
referrer,
{ from: accountAddress, value: ether(sendingEther) }
);
But before that, I want to test method first. So I move to this method:
const data = await instance.adoptCreeptomas.call(
aquaQuantity,
firaQuantity,
aetherQuantity,
gaiaQuantity,
referrer,
{ from: accountAddress, value: ether(sendingEther) }
);
But when calling this, I meet following exception:
errors.js:38 Uncaught (in promise) Error: Invalid JSON RPC response: {"id":6,"jsonrpc":"2.0","error":{"code":-32603}}
I am using ganache for local blockchain and metamask for provider. Please help me figure out why.
Thanks
adoptCreeptomaspersists some data to the blockchain (and also consume ether). That why I think we should "test" method first. I based on this: https://ethereum.stackexchange.com/questions/765/what-is-the-difference-between-a-transaction-and-a-call (Recommendation to Call first, then sendTransaction) – hqt May 22 '18 at 04:55web3.eth.contractsuppports. – viz May 22 '18 at 09:29web3.eth.contractis existed. But I don't know how to use this method. thanks. – hqt May 22 '18 at 09:34