-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
enhancementNew feature or improvement.New feature or improvement.fixed/completeThis Bug is fixed or Enhancement is complete and published.This Bug is fixed or Enhancement is complete and published.v6Issues regarding v6Issues regarding v6
Description
Ethers Version
6.2.2
Search Terms
abi
Describe the Problem
Use ABI from https://etherscan.io/address/0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714
simplify a bit and just use code as follow
export const abi = [ {
"name": "balances",
"outputs": [
{
"type": "uint256",
"name": ""
}
],
"inputs": [
{
"type": "int128",
"name": "arg0"
}
],
"constant": true,
"payable": false,
"type": "function"
},]
const contract = new Contract("0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714", abi as any, provider)
const func = contract.getFunction("balances(int128)")
const res = await func(0)
it will report:
Error: contract runner does not support sending transactions (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=6.2.2)
at makeError (file:///Users/fuyaoz/src/sample-ethers6/node_modules/ethers/src.ts/utils/errors.ts:663:21)
at assert (file:///Users/fuyaoz/src/sample-ethers6/node_modules/ethers/src.ts/utils/errors.ts:680:25)
at send (file:///Users/fuyaoz/src/sample-ethers6/node_modules/ethers/src.ts/contract/contract.ts:353:9)
at balances (file:///Users/fuyaoz/src/sample-ethers6/node_modules/ethers/src.ts/contract/contract.ts:395:22)
at file:///Users/fuyaoz/src/sample-ethers6/src/index.ts:183:19
at ModuleJob.run (node:internal/modules/esm/module_job:197:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:337:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:61:12) {
code: 'UNSUPPORTED_OPERATION',
operation: 'sendTransaction'
}
If I manually add "stateMutability": "view", to the ABI, then

notice the constant field of the fragment become true
Code Snippet
No response
Contract ABI
No response
Errors
No response
Environment
No response
Environment (Other)
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or improvement.New feature or improvement.fixed/completeThis Bug is fixed or Enhancement is complete and published.This Bug is fixed or Enhancement is complete and published.v6Issues regarding v6Issues regarding v6
