I have a smart contract deployed having the following function.

function getTime() public view returns (uint){
       return now;

However, when I try to call the function like this. ("einstance" being the instance of the contract):


I receive:

<Function getTime() bound to ()>

How can I retrieve the time from this?

3 Answers 3

// Web3 v1.2.6

const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));

const contractJSON = require('/path/to/build/contracts/Contract.json');
const contractInstance = new web3.eth.Contract(contractJSON.abi, 'CONTRACT_DEPLOYED_ADDRESS');

async function getTimeFromContract() {
  const time = await contractInstance.methods.getTime().call();
  console.log(`Time returned from the contract: ${time}`);

Try tme=einstance.call().getTime().

  • I get the following error!: MismatchedABI: ("The function 'call' was not found in this contract's abi. ", 'Are you sure you provided the correct contract abi?')
    – DebaSen
    Commented Feb 1, 2020 at 15:03
  • Sorry, the functions part is redundant. I mistakenly copied it from your question (where did you come up with that from anyway?). Commented Feb 1, 2020 at 15:10
  • Because when I write this: tme=einstance.getTime().call() I get the following error: 'Contract' object has no attribute 'getTime'
    – DebaSen
    Commented Feb 1, 2020 at 15:13
  • @DebaSen: How are you initializing the einstance object? Commented Feb 1, 2020 at 15:26

It depends on how you have deployed your contract. If it was deployed correctly then you can call.


where einstance must be instance of web3._utils.datatypes.Contract.

Little brief on how to install your contract

Step1: Compile your contract and get the bytecode and abi. You can install a specific version of sold compiler on your machine .

For abi
solc --abi test.sol

for bytecode
solc --bin test.sol

The instantiate by copying your abi and bytecode

Test = w3.eth.contract(abi=abi, bytecode=bytecode)

Then you have to deploy your contract, I did it on localchain

w3 = Web3("http://localhost:8545")
w3.eth.defaultAccount = w3.eth.accounts[0]  
tx_hash = Test.constructor().transact()
tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)

Your deployed contract

deployed = w3.eth.contract(

Now you can call the functions on your deployed contract by


I used this contract

pragma solidity 0.6.4;

contract Test {

    function getTime() public view returns (uint){
       return now;


Make sure your solc compiler (Installed on your machine) is same as in pragma statement.

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.