Skip to content
This repository has been archived by the owner on Aug 5, 2021. It is now read-only.

Read-Only Method is Sending a Transaction #309

Open
mudgen opened this issue Feb 21, 2020 · 1 comment
Open

Read-Only Method is Sending a Transaction #309

mudgen opened this issue Feb 21, 2020 · 1 comment

Comments

@mudgen
Copy link

mudgen commented Feb 21, 2020

The problem is that the call to "totalFunctions()" sends a transaction. But totalFunctions() is a read-only method on the contract.

I can't call any read-only methods. The culprit might be etherlime.ContractAt because that is what I need to use to access a contract and call its methods.

Using etherlime 2.2.6.

Here is my code:

const etherlime = require('etherlime-lib');

const DiamondExample = require('../build/DiamondExample.json');
const DiamondFacet = require('../build/DiamondFacet.json');


describe('DiamondExampleTest', () => {
    let aliceAccount = accounts[3];
    let deployer;
    let diamondFacet;

    before(async () => {
        deployer = new etherlime.EtherlimeGanacheDeployer(aliceAccount.secretKey);
        const diamondExample = await deployer.deploy(DiamondExample);
        
        console.log(diamondExample.contractAddress);
        diamondFacet = await etherlime.ContractAt(DiamondFacet, diamondExample.contractAddress);        
    });

    it('should get all the facets and functions of the contract', async () => {
        let total = await diamondFacet.totalFunctions();
        console.log(total); // We get transactions details instead of expected return value        
    });
});

Here is the abi for the totalFunctions() function:

  {
      "inputs": [],
      "name": "totalFunctions",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
@mudgen
Copy link
Author

mudgen commented Feb 25, 2020

Maybe the problem is related to the fact that I am using Solidity 0.6.3 and maybe something in the compiler json output changed? Just a wild guess.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant