lundi 13 décembre 2021

Web3 get ownership of smart contract returning execution reverted error

I'm using web3 in nodejs.

For getting ownership i've taken reference from

How to get ownership of smart contract using web3 Api Python?

I'm getting error while methods.owner().call(). other methods from ABI seems working fine. only owner method returning error.

Below is my code

const ABI = [{
  'constant': true, 'inputs': [], 'name': 'name', 'outputs': [{ 'name': '', 'type': 'string' }], 'payable': false, 'type': 'function',
}, {
  'constant': true, 'inputs': [], 'name': 'totalSupply', 'outputs': [{ 'name': '', 'type': 'uint256' }], 'payable': false, 'type': 'function',
}, {
  'constant': true, 'inputs': [], 'name': 'decimals', 'outputs': [{ 'name': '', 'type': 'uint8' }], 'payable': false, 'type': 'function',
}, {
  'constant': true, 'inputs': [{ 'name': '', 'type': 'address' }], 'name': 'balanceOf', 'outputs': [{ 'name': '', 'type': 'uint256' }], 'payable': false, 'type': 'function',
}, {
  'constant': true, 'inputs': [], 'name': 'symbol', 'outputs': [{ 'name': '', 'type': 'string' }], 'payable': false, 'type': 'function',
}, {
  'constant': true, 'inputs': [], 'name': 'owner', 'outputs': [{ 'name': '', 'type': 'address' }], 'payable': false, 'type': 'function',
}];


const Token = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

const totalSupply = await Token.methods.totalSupply().call();
const name = await Token.methods.name().call();
const symbol = await Token.methods.symbol().call();


const owner = await Token.methods.owner().call();

I've tried web3.eth.handleRevert = true; but seems there it is returning same error. with no reason.




Aucun commentaire:

Enregistrer un commentaire