Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Value not in range: 32 #59

Open
YDJSZY opened this issue Sep 6, 2019 · 37 comments
Open

Value not in range: 32 #59

YDJSZY opened this issue Sep 6, 2019 · 37 comments

Comments

@YDJSZY
Copy link

YDJSZY commented Sep 6, 2019

When I call your contract dart in example and it happend a error: Value not in range: 32
this is my code:

try {
      final balance = await web3client.call(
      contract: contract, function: balanceFunction, params: [ownAddress]);
      print('We have ${balance.first} MetaCoins');
    } catch (error) {
      print(error);
    }
@simolus3
Copy link
Owner

simolus3 commented Sep 6, 2019

Can you try replacing the catch statement with

catch (error, trace) {
  print(error);
  print(trace);
}

And give me the output of the stacktrace? Thanks!

@YDJSZY
Copy link
Author

YDJSZY commented Sep 6, 2019

RangeError: Value not in range: 32
I/flutter ( 675): #0 _rangeCheck (dart:typed_data-patch/typed_data_patch.dart:4445:5)
I/flutter ( 675): #1 _ByteBuffer.asUint8List (dart:typed_data-patch/typed_data_patch.dart:1923:5)
I/flutter ( 675): #2 _IntTypeBase.decode (package:web3dart/src/contracts/abi/integers.dart:23:31)
I/flutter ( 675): #3 TupleType.decode (package:web3dart/src/contracts/abi/tuple.dart:102:29)
I/flutter ( 675): #4 ContractFunction.decodeReturnValues (package:web3dart/src/contracts/abi/abi.dart:255:30)
I/flutter ( 675): #5 Web3Client.call (package:web3dart/src/core/client.dart:309:21)
I/flutter ( 675):
I/flutter ( 675): #6 EthSdkClient.sendErc20Transaction (package:flutter_tic_wallet/packages/blockChainSdk/eth/index.dart:103:40)
I/flutter ( 675):
I/flutter ( 675): #7 BlockChainSdk.sendErc20Transaction (package:flutter_tic_wallet/packages/blockChainSdk/index.dart:56:9)
I/flutter ( 675): #8 main (package:flutter_tic_wallet/main.dart:35:17)
I/flutter ( 675):
I/flutter ( 675): #9 _runMainZoned.. (dart:ui/hooks.dart:216:25)
I/flutter ( 675): #10 _rootRun (dart:async/zone.dart:1124:13)
I/flutter ( 675): #11 _CustomZone.run (dart:a

@simolus3
Copy link
Owner

simolus3 commented Sep 6, 2019

Thank you for the report. This seems similar to #47 (comment), so a bit more information would be helpful to find the cause

  1. are you running the latest flutter version? We had a very similar bug that was actually caused by Flutter
  2. does is only happen for release builds or for debug builds as well?
  3. (optional) To make debugging easier for me, can you attach a logger to the HttpClient you pass to the Web3Client constructor? The comment linked above contains information on how to do that. This lets me inspect the raw data returned from the contract. Be aware that these calls could contain potentially sensitive information (your Ethereum node, address, contract address, payload you send to the contract). You can strip out some information if you like or, if you don't want to post these details publicly, e-mail them to me at [email protected].

@YDJSZY
Copy link
Author

YDJSZY commented Sep 6, 2019

Thanks for your detail reply!
I change your abi.json to https://github.com/danfinlay/human-standard-token-abi, and it work! it return my erc20 token balance successfully.
my contract address is 0x01e5ad4f8fb032f80ec0e3de7f4221b46f81d4c9 and my eth address is
0x6c0d0870ec3af6411332f9524640e7f781941e0e.
I used your abi.json, your privateKey and contract before, but it showed error "Value not in range: 32"

@YDJSZY
Copy link
Author

YDJSZY commented Sep 6, 2019

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.7.8+hotfix.2, on Mac OS X 10.13.6 17G65, locale zh-Hans-CN)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.1)
[!] iOS tools - develop for iOS devices
✗ ios-deploy out of date (1.9.4 is required). To upgrade with Brew:
brew upgrade ios-deploy
[✓] Android Studio (version 3.1)
[!] IntelliJ IDEA Ultimate Edition (version 2019.2)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.37.1)
[✓] Connected device (1 available)

! Doctor found issues in 2 categories.
I just run in android simulator. I think it maybe doesn't matter with flutter version.

@simolus3
Copy link
Owner

simolus3 commented Sep 6, 2019

Oh interesting! The abi from the repo you linked doesn't define a "getBalance" function, it has a "balanceOf" function instead. They both declare the same return types though, so I'm surprised that didn't work. I'll take a more detailed look later.

@AyushBherwani1998
Copy link

Hey @simolus3 , I'm still getting this error. I checked, the function is available in the abi.json and also on the smart contract.

await ethClient.call(
        contract: contract,
        function: checkOrgan,
        params: [user.bloodGroup,model.organDescription]).catchError((error,trace){
          Logger(printer: PrettyPrinter()).e("Error: $error");
    })

@AyushBherwani1998
Copy link

Trace:

I/flutter ( 4767): #0 _rangeCheck (dart:typed_data-patch/typed_data_patch.dart:4631:5)
I/flutter ( 4767): #1 _ByteBuffer.asUint8List (dart:typed_data-patch/typed_data_patch.dart:1931:5)
I/flutter ( 4767): #2 BoolType.decode (package:web3dart/src/contracts/abi/integers.dart:132:28)
I/flutter ( 4767): #3 TupleType.decode (package:web3dart/src/contracts/abi/tuple.dart:102:29)
I/flutter ( 4767): #4 ContractFunction.decodeReturnValues (package:web3dart/src/contracts/abi/abi.dart:255:30)
I/flutter ( 4767): #5 Web3Client.call (package:web3dart/src/core/client.dart:310:21)
I/flutter ( 4767):
I/flutter ( 4767): #6 ReceiveViewButton.checkAvailability (package:organ_donation/widgets/receive_organ/receive_button.dart:59:33)
I/flutter ( 4767):
I/flutter ( 4767): #7 ReceiveViewButton.build. (package:organ_donation/widgets/receive_organ/receive_button.dart:38:13)
I/flutter ( 4767): #8 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
I/flutter ( 4767): #9 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:789:36)
I/flutter ( 4767): #10 GestureRecognizer.invokeCallback (packag

@simolus3
Copy link
Owner

simolus3 commented Mar 6, 2020

@AyushBherwani1998 Can you sent me the part of the contract abi that defines the checkOrgan function?

@AyushBherwani1998
Copy link

Here is the snippet from abi.json

  {
    "constant": true,
    "inputs": [
      {
        "name": "bloodGroup",
        "type": "string"
      },
      {
        "name": "description",
        "type": "string"
      }
    ],
    "name": "checkOrgan",
    "outputs": [
      {
        "name": "",
        "type": "bool"
      }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  }

@AyushBherwani1998
Copy link

@simolus3 Any updates on the issue?

@simolus3
Copy link
Owner

Sorry for the delay - unfortunately I couldn't find a bug in web3dart here. We have tests to verify that booleans are encoded and decoded correctly.

Can you try attaching a logger to the http client (for instance like this) and post what the eth_call request returns? If you're uncomfortable posting that publicly you can also send it to me at [email protected].

@kevin-sakemaer
Copy link

i got this error today with a function in the aave contract with no boolean involved only uint256 but the bug is not always here will investigate more if it reproduce

@kevin-sakemaer
Copy link

here i got a stacktrace

RangeError: Value not in range: 128
#0      _rangeCheck (dart:typed_data-patch/typed_data_patch.dart:4791:5)
#1      _ByteBuffer.asUint8List (dart:typed_data-patch/typed_data_patch.dart:1931:5)
#2      _IntTypeBase.decode (package:web3dart/src/contracts/abi/integers.dart:29:31)
#3      TupleType.decode (package:web3dart/src/contracts/abi/tuple.dart:102:29)
#4      ContractFunction.decodeReturnValues (package:web3dart/src/contracts/abi/abi.dart:257:30)
#5      Web3Client.call (package:web3dart/src/core/client.dart:314:21)
<asynchronous suspension>
#6      LendingPool.getUserAccountData (package:aave_sdk/src/contracts/lending_pool.dart:328:34)
#7      main (file:///Users/kleak/Work/github.com/no-loss-investor-wallet/aave_sdk/bin/get_health_factor.dart:26:48)
<asynchronous suspension>
#8      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
#9      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

@kevin-sakemaer
Copy link

in lib/src/crypto/formatting.dart when i print bytes.toList() i got this :

[8, 195, 121, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 83, 97, 102, 101, 77, 97, 116, 104, 58, 32, 115, 117, 98, 116, 114, 97, 99, 116, 105, 111, 110, 32, 111, 118, 101, 114, 102, 108, 111, 119, 0, 0]

so here we have a 100 element List but then in lib/src/contracts/abi/integers.dart
if here i print the offset it got 96 with sizeUnitBytes at 32 this lead us to 128 which in above the 100 element array which lead to the error.

@kevin-sakemaer
Copy link

i call the method getUserAccountData there is the return type here https://developers.aave.com/#lendingpool

Notice that not all call fail but only some of them which render the task of debugging it pretty complicated.

@simolus3
Copy link
Owner

i call the method getUserAccountData there is the return type here https://developers.aave.com/#lendingpool

Interesting. That method returns 8 uint256 values, so I'd also expect 256 bytes of payload data - it weird that we only get 100.
I think the decoding failing here is correct - the 100 byte list just can't be decoded as 8 values of that type. It's worth investigating why we don't get a complete result though - what node are you connecting to? Or do you have a way for me to reproduce this?

@kevin-sakemaer
Copy link

i'm on mainnet and i can provide you an address that fail everytime.
0x338a370bd32b454345182365b380664cbe660998
I will open source my aave sdk soon (next week) so it will be easier to test everything.

@AyushBherwani1998
Copy link

AyushBherwani1998 commented Mar 14, 2020

@simolus3 Here are the logs

sending https://rinkeby.infura.io/v3/b306ccbea4ad48aa97a9xxxxxx5970 with {"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0xdce881db68e093637378083611367dac5bb7ce3b","data":"0xace8a4af000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000
0000000000000000000000000000024f2b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064b69646e65790000000000000000000000000000000000000000000000000000"},"latest"],"id":1}
I/flutter ( 9100): response:
I/flutter ( 9100): {"jsonrpc":"2.0","id":1,"result":"0x"}

@simolus3
Copy link
Owner

Thanks a lot @AyushBherwani1998! I can reproduce this problem locally. I think this might be an infura bug: INFURA/infura#157
It's pretty weird that we get this error consistently though, and not just occasionally. It looks infura returns 0x instead of throwing an error when calling an invalid address - are you sure 0xdce881db68e093637378083611367dac5bb7ce3b is correct? I also noticed you're passing O+ (the letter) instead of 0+ (the number) as bloodGroup, but I guess that shouldn't matter for this error.

@AyushBherwani1998
Copy link

Thanks a lot @AyushBherwani1998! I can reproduce this problem locally. I think this might be an infura bug: INFURA/infura#157
It's pretty weird that we get this error consistently though, and not just occasionally. It looks infura returns 0x instead of throwing an error when calling an invalid address - are you sure 0xdce881db68e093637378083611367dac5bb7ce3b is correct? I also noticed you're passing O+ (the letter) instead of 0+ (the number) as bloodGroup, but I guess that shouldn't matter for this error.

This sounds weird. The address is correct. I'm able to do transactions but not able to call functions.

@ltfschoen
Copy link

I had the same error.
It was because although I was using the correct abiCode that corresponded to the latest version of the smart contract I was calling, I had provided a contractAddr that corresponded to a different smart contract all together. So I just provided the correct smart contract address to contractAddr to fix the issue. See code snippet below:

final contract = DeployedContract(
        ContractAbi.fromJson(abiCode, 'DataHighwayMXCMiningToken'),
        contractAddr);
final getStuffFunction = contract.function('getStuff');
await client.call(
        contract: contract,
        function: getStuffFunction,
        params: [ownAddress]);

@drexel-ue
Copy link

drexel-ue commented Dec 16, 2020

Hey, Ive read through the comments and it doesn't seem like a resolution was found

I'm experiencing a similar issue using ganache-cli

I'd love to dive in and provide any information needed.

dart funtion ran:

@override
  Future<void> checkUserBalance() async {
    final result = await _client.call(
      contract: _tokenContract,
      function: _balanceOf,
      params: [_ownAddress],
    );

    print(result);
  }

balanceOf definition
_balanceOf = _tokenContract.function('balanceOf');

http logs:

flutter: sending http://[ip]:8545 with {"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0x0e0371a25984ddeacf36827c8768561430294572","data":"0x70a082310000000000000000000000004661e0543ad3dfa8a62bd19deb3b6719d7d8f561"},"latest"],"id":1}
flutter: response:
{"id":1,"jsonrpc":"2.0","result":"0x"}

I'm curious, why is the method eth_call should it not be referencing balanceOf ?

@drexel-ue
Copy link

Here is the repo if anyone is curious: https://github.com/drexel-ue/eth_swap

@ag-0214
Copy link

ag-0214 commented Jul 24, 2021

I am stuck with this error. Couldnt find any solution, did anyone managed to get the solution

I/flutter (20363): sending https://ropsten.infura.io/v3/78b90db8ffa14e85848a478a7a4b3e22 with {"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0x6661ba2d65552ae933a7135cd8e24d05a9ecd46e","data":"0x70a082310000000000000000000000007ab70bdc3a9b8fa75ae2a6256e3c926e7730baa7"},"latest"],"id":2}
I/flutter (20363): response:
I/flutter (20363): {"jsonrpc":"2.0","id":2,"result":"0x"}
I/flutter (20363): error: RangeError: Value not in range: 32
I/flutter (20363): trace: #0 _rangeCheck (dart:typed_data-patch/typed_data_patch.dart:4951:5)
I/flutter (20363): #1 _ByteBuffer.asUint8List (dart:typed_data-patch/typed_data_patch.dart:1911:5)
I/flutter (20363): #2 _IntTypeBase.decode
package:web3dart/…/abi/integers.dart:37
I/flutter (20363): #3 TupleType.decode
package:web3dart/…/abi/tuple.dart:106
I/flutter (20363): #4 ContractFunction.decodeReturnValues
package:web3dart/…/abi/abi.dart:266
I/flutter (20363): #5 Web3Client.call
package:web3dart/…/core/client.dart:341

@GaryPate
Copy link

GaryPate commented Jul 31, 2021

Hey, does anyone have any links to resolution of this error?

I am attempting to authenticate a challenge string and coming up with a similar error in flutter.

I/flutter (26723): [151, 184, 247, 173, 50, 121, 96, 31, 147, 182, 253, 127, 173, 252, 156, 23, 164, 45, 17, 211, 108, 102, 57, 170, 127, 108, 55, 130, 3, 51, 89, 176]
E/flutter (26723): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: RangeError (start): Invalid value: Not in inclusive range 0..32: -32
E/flutter (26723): #0      RangeError.checkValidRange (dart:core/errors.dart:328:7)
E/flutter (26723): #1      _TypedIntListMixin.setRange (dart:typed_data-patch/typed_data_patch.dart:394:18)
E/flutter (26723): #2      _RFC6979KCalculator._init
package:pointycastle/signers/ecdsa_signer.dart:304
E/flutter (26723): #3      new _RFC6979KCalculator
package:pointycastle/signers/ecdsa_signer.dart:294
E/flutter (26723): #4      ECDSASigner.generateSignature
package:pointycastle/signers/ecdsa_signer.dart:102
E/flutter (26723): #5      sign
package:web3dart/…/crypto/secp256k1.dart:75
E/flutter (26723): #6      EthPrivateKey.signToSignature
package:web3dart/…/credentials/credentials.dart:110
E/flutter (26723): #7      signChallenge
package:trypto_redux/streamr/streamr_util.dart:80
E/flutter (26723): #8      jsonResponse
package:trypto_redux/streamr/streamr_util.dart:90
E/flutter (26723): #9      authenticateStreamr
package:trypto_redux/streamr/streamr_util.dart:188
E/flutter (26723): <asynchronous suspension>
E/flutter (26723):

@GaryPate
Copy link

GaryPate commented Jul 31, 2021

I am attempting to sign a challenge string in the following way

Future<MsgSignature> signChallenge(String challenge) async {
  final privateKey = getPrivateKey();
  final privateKeyU = utf8.encoder.convert(privateKey);
  final challengeU = keccakAscii(challenge);
  var privateKeyW3 = EthPrivateKey(privateKeyU);
  var signedChallenge = privateKeyW3.signToSignature(challengeU);

@John1Fazio
Copy link

I'm experiencing this same issue (September 20, 2021) - If anyone is available to help me out with this one I'll be more than willing to reply with my source code/more details. It's been a while since somebody has been able to offer some help on the matter but let me know if there are any signs of life ahah

@simolus3
Copy link
Owner

This happens if the RPC endpoint replies with 0x, an invalid response that cannot be parsed into the return values indicated in the ABI. The question is why that happens. If anyone has a contract with sources on a public net (can be a testnet) that reproduces this, I'd love to take a look.

@John1Fazio
Copy link

RPC endpoint replies with 0x, an invalid response that cannot be parsed into the return values indicated in the ABI.

you can view the contract source at this address on the ropsten testnet:

0xA8c53a4D9e1D47A0E2ECCA6bd0334445541ce88F

@John1Fazio
Copy link

John1Fazio commented Sep 22, 2021

RPC endpoint replies with 0x, an invalid response that cannot be parsed into the return values indicated in the ABI.

you can view the contract source at this address on the ropsten testnet:

0xA8c53a4D9e1D47A0E2ECCA6bd0334445541ce88F

I've found the source of the error and it was related to an improper use of the Convert dart package (for decoding/encoding the json abi) rather than an error brought on by Web3dart or the implementation thereof. I adjusted this and the code worked wonderfully. Thanks as well to simolus3 for reaching out.

@IsaacBSDS
Copy link

IsaacBSDS commented Nov 7, 2021

Hi, I got the same error trying to call Uniswap's "addLiquidity" function.

Future<DeployedContract> _loadContractUniSwap(
      String hexContractAddress) async {
    String abi = await rootBundle.loadString("assets/abi_uniswap.json");
    EthereumAddress address = EthereumAddress.fromHex(hexContractAddress);
    DeployedContract contract =
        DeployedContract(ContractAbi.fromJson(abi, ""), address);

    return contract;
  }
Future addLiquity(
    String tokenA,
    String tokenB,
    BigInt amountADesired,
    BigInt amountBDesired,
    BigInt amountAMin,
    BigInt amountBMin,
    String to,
    String hexContractAddress,
    BigInt deadLine,
  ) async {
    DeployedContract contract = await _loadContractUniSwap(hexContractAddress);
    ContractFunction ethFunction = contract.function("addLiquidity");
    EthereumAddress ethAddressTokenA = EthereumAddress.fromHex(tokenA);
    EthereumAddress ethAddressTokenB = EthereumAddress.fromHex(tokenB);
    EthereumAddress ethTo = EthereumAddress.fromHex(to);
    try {
      final result = await ethClient!
          .call(contract: contract, function: ethFunction, params: [
        ethAddressTokenA,
        ethAddressTokenB,
        amountADesired,
        amountBDesired,
        amountAMin,
        amountBMin,
        ethTo,
        deadLine,
      ]);
      return result;
    } catch (error, trace) {
      print(error);
      print(trace);
    }
  }
I/flutter ( 3389): RangeError: Value not in range: 32
I/flutter ( 3389): #0      _rangeCheck (dart:typed_data-patch/typed_data_patch.dart:4951:5)
I/flutter ( 3389): #1      _ByteBuffer.asUint8List (dart:typed_data-patch/typed_data_patch.dart:1911:5)
I/flutter ( 3389): #2      _IntTypeBase.decode
package:web3dart/…/abi/integers.dart:37
I/flutter ( 3389): #3      TupleType.decode
package:web3dart/…/abi/tuple.dart:106
I/flutter ( 3389): #4      ContractFunction.decodeReturnValues
package:web3dart/…/abi/abi.dart:273
I/flutter ( 3389): #5      Web3Client.call
package:web3dart/…/core/client.dart:354
I/flutter ( 3389): <asynchronous suspension>
I/flutter ( 3389): #6      _MyHomePageState.addLiquity
package:uniswap_test/main.dart:147
I/flutter ( 3389): <asynchronous suspension>

@ordinatorix
Copy link

Had this issue when I was trying to use a contract that was not deployed on the network.

Maybe that could help.

@kartikey321
Copy link

RPC endpoint replies with 0x, an invalid response that cannot be parsed into the return values indicated in the ABI.

you can view the contract source at this address on the ropsten testnet:
0xA8c53a4D9e1D47A0E2ECCA6bd0334445541ce88F

I've found the source of the error and it was related to an improper use of the Convert dart package (for decoding/encoding the json abi) rather than an error brought on by Web3dart or the implementation thereof. I adjusted this and the code worked wonderfully. Thanks as well to simolus3 for reaching out.

@John1Fazio can you please share the code that you adjusted?

@kartikey321
Copy link

Hey @simolus3 Is there any update on the issue? I am still facing it
image

@John1Fazio
Copy link

John1Fazio commented Jan 18, 2022

RPC endpoint replies with 0x, an invalid response that cannot be parsed into the return values indicated in the ABI.

you can view the contract source at this address on the ropsten testnet:
0xA8c53a4D9e1D47A0E2ECCA6bd0334445541ce88F

I've found the source of the error and it was related to an improper use of the Convert dart package (for decoding/encoding the json abi) rather than an error brought on by Web3dart or the implementation thereof. I adjusted this and the code worked wonderfully. Thanks as well to simolus3 for reaching out.

@John1Fazio can you please share the code that you adjusted?

It's been a while since this issue, so I'm foggy on the details. Following this code, you should be able to connect to Web3Dart and call functions on your smart contract. The private key and my infura key are omitted for obvious reasons.

Let me know if this is even helpful. If not, I may be able to share more code.

`import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart';
import 'package:web3dart/web3dart.dart';

class MainModel {
  Client? httpClient;
  Web3Client? ethClient;
  String apiUrl =
      ''; //RPC url goes here

  MainModel() {
    initiateSetup();
    print("connected to the blockchain at: $apiUrl");
  }

  Future<void> initiateSetup() async {
    httpClient = Client();
    ethClient = Web3Client(apiUrl, httpClient!);

    await getCredentials();
    await getDeployedContract();
    await getContractFunctions();
  }

  String privateKey =
      '';
      //privatekey goes here
  Credentials? credentials;
  EthereumAddress? myAddress;

  Future<void> getCredentials() async {
    final credentials = EthPrivateKey.fromHex(privateKey);
    myAddress = await credentials.extractAddress();
  }

  EthereumAddress? contractAddress;

  Future<void> getDeployedContract() async {

    contractAddress =
        EthereumAddress.fromHex('0xBDF17b9291673964BC410324169780C024608C8d');
  }

  DeployedContract? contract;
  ContractFunction? mint,
      burn,
      tokenURI,
      approve,
      transferFrom,
      balanceOf,
      getApproved,
      isApprovedForAll,
      name,
      symbol,
      ownerOf,
      supportsInterface;

  Future<void> getContractFunctions() async {
    String abi = await rootBundle.loadString('src/artifacts/NFT.json');
    contract =
        DeployedContract(ContractAbi.fromJson(abi, "NFT"), contractAddress!);
    print(contractAddress);
    //TRANSACTIONS
    mint = contract!.function('mint');
    burn = contract!.function('burn');
    approve = contract!.function('approve');
    transferFrom = contract!.function('transferFrom');
    //CALLS
    balanceOf = contract!.function('balanceOf');
    getApproved = contract!.function('getApproved');
    isApprovedForAll = contract!.function('isApprovedForAll');
    name = contract!.function('name');
    symbol = contract!.function('symbol');
    ownerOf = contract!.function('ownerOf');
    tokenURI = contract!.function('tokenURI');
    supportsInterface = contract!.function('supportsInterface');
  }


  Future<List<dynamic>> readContract(
    ContractFunction functionName,
    List<dynamic> functionArgs,
  ) async {
    try {
      var queryResult = await ethClient!.call(
        contract: contract!,
        function: functionName,
        params: functionArgs,
      );
      return queryResult;
    } catch (error, trace) {
      print(error);
      print(trace);
      throw error;
    }
  }


  Future<void> writeContract(
    ContractFunction functionName,
    List<dynamic> functionArgs,
  ) async {
    await ethClient!.sendTransaction(
        credentials!,
        Transaction.callContract(
          contract: contract!,
          function: functionName,
          parameters: functionArgs,
        ),
        chainId: 3);
  }
}`

@ndungudedan
Copy link

I experienced this but managed to solve it by changing to Injected Web3 Environment..
Am using the Ropsten Test Network

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests