I'm attempting to call a method on a locally deployed contract with the following code using web3 JS 1.0.0-beta30.

const tradingCardABI = JSON.parse(fs.readFileSync('build/contracts/TradingCard.json')).abi;

const ownerAddress = process.env.OWNER_ADDRESS || '0x627306090abaB3A6e1400e9345bC60c78a8BEf57';
const contractAddress = process.env.CONTRACT_ADDRESS || '0xf25186b5081ff5ce73482ad761db0eb0d25abfbf';

const tradingCardContract = new web3.eth.Contract(tradingCardABI, contractAddress);

console.log(`contract json interface=${JSON.stringify(tradingCardContract.options.jsonInterface)}`);
console.log(`contract models=${JSON.stringify(tradingCardContract.methods)}`);

I get contract methods={} in the console. Any thoughts?


I've tried the same and was wondering why the methods object is empty. I tried to console.log the instance.methods directly which gave me an error, that ... can't be shown.

Then I simply tried to call a function from this "empty" object and it worked as it supposed to.

So the answer is, that you can call the methods even if they don't show in your json output.

Use the following code to call the methods:

YOURINSTANCE.methods.YOUR_METHOD().call().then(ret => {

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.