Ethers.js: Internal JSON-RPC error code -32603

Created on 13 May 2021  ·  11Comments  ·  Source: ethers-io/ethers.js

React App - Brave 5_13_2021 9_30_30 PM (3)

I'm encountering this error when calling a function that returns a string stored in the contract.

This is the ABI

{
"inputs": [],
"name": "getContractName",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
}

The weird thing is I have another contract in the project that also has a function that returns a string stored in the contract and that one does not trigger the error when calling it, it's ABI being identical to what's above. What additional information should I provide to figure this out? Thanks for dropping by ^^

investigate

All 11 comments

Hey can you try the following if it helps

  • are you on the right network in metamask network
  • can you check if your contract address is correct (if it is an address which isn't a contract or a contract that doesn't have this method then you will get a similar error)

@zemse I have checked, I am on the right network and also it is a correct contract address - if I take the contract and log it in the console, I can see the problematic function there.

@Alexhandru Are you still facing this issue?

const contractAddr = contract.address;
const provider = contract.provider; // using the same provider in your contract
const code = await provider.getCode(contractAddr)
console.log(code)

Can you console log the above?

@zemse Still having the issue and it's killing me because it's the application part for my thesis and the more time passes, the more stressed I'm getting that I won't finish it in time XD So I'm really appreciating your help ^^
I console logged the code, and the following is showing:

0x608060405234801561001057600080fd5b50600436106101005760003560e01c806391d1485411610097578063ca15c87311610066578063ca15c8731461063f578063ccba257b14610681578063d547741f1461075c578063f7be43fb146107aa57610100565b806391d148541461049e578063a217fddf14610502578063a7d1595214610520578063aec37eb3146105e557610100565b806336568abe116100d357806336568abe146102b95780635e8b80911461030757806382f7d392146103e25780639010d07c1461043c57610100565b806319f0b63014610105578063248a9ca3146101645780632594f3fe146101a65780632f2ff15d1461026b575b600080fd5b61010d6107c8565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610150578082015181840152602081019050610135565b505050509050019250505060405180910390f35b6101906004803603602081101561017a57600080fd5b81019080803590602001909291905050506108c4565b6040518082815260200191505060405180910390f35b610269600480360360408110156101bc57600080fd5b8101908080359060200190929190803590602001906401000000008111156101e357600080fd5b8201836020820111156101f557600080fd5b8035906020019184600183028401116401000000008311171561021757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506108e3565b005b6102b76004803603604081101561028157600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a37565b005b610305600480360360408110156102cf57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac0565b005b6103e06004803603604081101561031d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561035a57600080fd5b82018360208201111561036c57600080fd5b8035906020019184600183028401116401000000008311171561038e57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050610b59565b005b610424600480360360208110156103f857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610caa565b60405180821515815260200191505060405180910390f35b6104726004803603604081101561045257600080fd5b810190808035906020019092919080359060200190929190505050610cdd565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104ea600480360360408110156104b457600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d0e565b60405180821515815260200191505060405180910390f35b61050a610d3f565b6040518082815260200191505060405180910390f35b6105e36004803603604081101561053657600080fd5b81019080803590602001909291908035906020019064010000000081111561055d57600080fd5b82018360208201111561056f57600080fd5b8035906020019184600183028401116401000000008311171561059157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050610d46565b005b610627600480360360208110156105fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e13565b60405180821515815260200191505060405180910390f35b61066b6004803603602081101561065557600080fd5b8101908080359060200190929190505050610e29565b6040518082815260200191505060405180910390f35b61075a6004803603608081101561069757600080fd5b8101908080359060200190929190803590602001906401000000008111156106be57600080fd5b8201836020820111156106d057600080fd5b803590602001918460018302840111640100000000831117156106f257600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190803515159060200190929190505050610e4f565b005b6107a86004803603604081101561077257600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111b9565b005b6107b2611242565b6040518082815260200191505060405180910390f35b6060600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461082457600080fd5b606060028054806020026020016040519081016040528092919081815260200182805480156108a857602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001906001019080831161085e575b50505050509050600260006108bd9190611662565b8091505090565b6000806000838152602001908152602001600020600201549050919050565b6108ec33610caa565b61095e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f5265737472696374656420746f2061646d696e7321000000000000000000000081525060200191505060405180910390fd5b60006003600084815260200190815260200160002090508060010160009054906101000a900460ff166109dc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806117726022913960400191505060405180910390fd5b818160030160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209080519060200190610a31929190611683565b50505050565b610a5d60008084815260200190815260200160002060020154610a58611296565b610d0e565b610ab2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180611743602f913960400191505060405180910390fd5b610abc828261129e565b5050565b610ac8611296565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610b4b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f8152602001806117e9602f913960400191505060405180910390fd5b610b558282611331565b5050565b610b6233610e13565b610bd4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f5265737472696374656420746f2061646d696e7321000000000000000000000081525060200191505060405180910390fd5b610bfe7fe898e77115f00dcda73cfc4c764c000e9321c213165627895a7e873dce9bd78983610a37565b816004826040518082805190602001908083835b60208310610c355780518252602082019150602081019050602083039250610c12565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b6000610cd67fe898e77115f00dcda73cfc4c764c000e9321c213165627895a7e873dce9bd78983610d0e565b9050919050565b6000610d06826000808681526020019081526020016000206000016113c490919063ffffffff16565b905092915050565b6000610d37826000808681526020019081526020016000206000016113de90919063ffffffff16565b905092915050565b6000801b81565b610d4f33610e13565b610dc1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f5265737472696374656420746f2061646d696e7321000000000000000000000081525060200191505060405180910390fd5b600060036000848152602001908152602001600020905081816000019080519060200190610df0929190611683565b5060018160010160006101000a81548160ff021916908315150217905550505050565b6000610e226000801b83610d0e565b9050919050565b6000610e4860008084815260200190815260200160002060000161140e565b9050919050565b610e5833610e13565b610eca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f5265737472696374656420746f2061646d696e7321000000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166004846040518082805190602001908083835b60208310610f185780518252602082019150602081019050602083039250610ef5565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610fd9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806117946025913960400191505060405180910390fd5b6000600360008681526020019081526020016000209050828160020160006004876040518082805190602001908083835b6020831061102d578051825260208201915060208101905060208303925061100a565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081156111b25760026004856040518082805190602001908083835b602083106110fd57805182526020820191506020810190506020830392506110da565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5050505050565b6111df600080848152602001908152602001600020600201546111da611296565b610d0e565b611234576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260308152602001806117b96030913960400191505060405180910390fd5b61123e8282611331565b5050565b7fe898e77115f00dcda73cfc4c764c000e9321c213165627895a7e873dce9bd78981565b600061128e836000018373ffffffffffffffffffffffffffffffffffffffff1660001b611423565b905092915050565b600033905090565b6112c58160008085815260200190815260200160002060000161126690919063ffffffff16565b1561132d576112d2611296565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b6113588160008085815260200190815260200160002060000161149390919063ffffffff16565b156113c057611365611296565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b60006113d383600001836114c3565b60001c905092915050565b6000611406836000018373ffffffffffffffffffffffffffffffffffffffff1660001b611546565b905092915050565b600061141c82600001611569565b9050919050565b600061142f8383611546565b61148857826000018290806001815401808255809150506001900390600052602060002001600090919091909150558260000180549050836001016000848152602001908152602001600020819055506001905061148d565b600090505b92915050565b60006114bb836000018373ffffffffffffffffffffffffffffffffffffffff1660001b61157a565b905092915050565b600081836000018054905011611524576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806117216022913960400191505060405180910390fd5b82600001828154811061153357fe5b9060005260206000200154905092915050565b600080836001016000848152602001908152602001600020541415905092915050565b600081600001805490509050919050565b6000808360010160008481526020019081526020016000205490506000811461165657600060018203905060006001866000018054905003905060008660000182815481106115c557fe5b90600052602060002001549050808760000184815481106115e257fe5b906000526020600020018190555060018301876001016000838152602001908152602001600020819055508660000180548061161a57fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061165c565b60009150505b92915050565b50805460008255906000526020600020908101906116809190611703565b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106116c457805160ff19168380011785556116f2565b828001600101855582156116f2579182015b828111156116f15782518255916020019190600101906116d6565b5b5090506116ff9190611703565b5090565b5b8082111561171c576000816000905550600101611704565b509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e744c61626f7261746f7279207375626d697373696f6e732061726520636c6f7365642153747564656e7420776974682074686973206e616d65206e6f742079657420616464656421416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b65416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a264697066735822122046d0e7148d6e6f226df21694bc106b006d8cb00bcbf50e6ffe4ea952ce6b8bcb64736f6c634300060c0033

Thanks for sharing. The function getContractName() (signature: 0xf5f5ba72) doesn't seem to be exposed in the bytecode.

  • Can you check if that function is public or external
  • If its public in your solidity code (but can't see it in the decompiled bytecode), then was some other contract deployed instead of the one which you intended to be deployed?

@zemse oops, my bad. getContractName() was a generic name I gave to the actual problematic function that is "getCourseName".

Even the method getCourseName (signature: 0xacf2b4e7) doesn't appear to be present in the bytecode.

@zemse It is present in my ABI from which I instanced it in the application. The question is what am I doing then wrong, that it is not present in the bytecode?
React App - Brave 5_18_2021 4_24_14 PM (2)_LI

If you have your ABI and you pass any arbitrary address, still ethers.js will give you the Contract object like above. But if that arbitrary address doesn't have the particular method which you are using then it would give you an error like what you're getting.

There is no good way to verify if a method exists or not in the deployed contract, other than analyzing the bytecode or actually trying to use the method.

The question is what am I doing then wrong, that it is not present in the bytecode?

I think since you are working with multiple contracts: lets say A and B. A has the method "getCourseName" while B doesn't. Now in your application you may likely have instanced the ethers.Contract object with abi of A while passing in address of B. That's why in bytecode you shared, there are lot of methods present while 0xacf2b4e7 (getCourseName()) wasn't

I don’t think this is an error with ethers, so I’m going to convert it to a discussion where it can continue to be investigated and resolved. Thanks for helping with this @zemse! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gitpusha picture gitpusha  ·  25Comments

Tomix3D picture Tomix3D  ·  39Comments

elenadimitrova picture elenadimitrova  ·  28Comments

fmsouza picture fmsouza  ·  44Comments

subramanianv picture subramanianv  ·  34Comments