methods.myMethod.call not return value I wanted

by shuzang   Last Updated October 09, 2019 07:28 AM

I am attempt to get an address using methods.call(). And it's something error.

JS

var rcAddr = "0x683d1602fa7252d49cda8ac414c1641a56e73d03";
var methodName = "Access Control";
var register = new web3.eth.Contract(rcAbi, rcAddr);
var accAddr = register.methods.getContractAddr(methodName).call({
    from: "0x70f99451d9878055ca8986021ca78f6edb8f1720",
    gas: 10000000
});
console.log(accAddr)

solidity

 function getContractAddr(string memory _methodName) public view returns (address _scAddress){
        bytes32 key = stringToBytes32(_methodName);
        _scAddress = lookupTable[key].scAddress;
    }
}

I think I can get a address from function, but it's wrong. So I use console.log(accAddr) output the result.

Promise {
  _bitField: 0,
  _fulfillmentHandler0: undefined,
  _rejectionHandler0: undefined,
  _promise0: undefined,
  _receiver0: undefined }

It return something else. I'm confused. methods.myMethod.call in document say

Returns
Promise returns Mixed: The return value(s) of the smart contract method. If it returns a single value, it’s returned as is. If it has multiple return values they are returned as an object with properties and indices:

So It should return the value but why not.

Tags : web3js


Related Questions


Updated January 06, 2019 18:28 PM

Updated December 20, 2018 15:28 PM

Updated August 09, 2019 05:28 AM

Updated August 12, 2019 09:28 AM

Updated September 04, 2019 13:28 PM