I am trying to call the balanceOf function in a pretty barebones openzepplin ERC1155 contract through metamask.

I am using web3 only to generate the ABI, and metamask to actually send out the call.

Here is my code for the call,

const call = web3.eth.abi.encodeFunctionCall(
        name: 'balanceOf',
        type: 'function',
        inputs: [
            type: 'address',
            name: 'account',
            type: 'uint256',
            name: 'id',
      [account, 0]
    // const from = account
    // /// 0x6c90b4eb
    return window.ethereum.request({
      method: 'eth_call',
      params: [
          to: '0x7889d99522630E457cD522493eB7dE1C17e90a9D',
          data: call,

and my code for the contract is here

pragma solidity ^0.6.0;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

contract GameItems is ERC1155 {
    uint256 public constant GOLD = 0;
    uint256 public constant THORS_HAMMER = 1;

    constructor() public ERC1155("https://URL.XYZ/{id}.json") {
        _mint(msg.sender, GOLD, 100, "");
        _mint(msg.sender, THORS_HAMMER, 1, "");

I am running it on ganache, which shows only one contract being made, which is this one. The address being passed in is not undefined and is the owner of the contract.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.