flutter_web3_provider icon indicating copy to clipboard operation
flutter_web3_provider copied to clipboard

dart.global.ethers is undefined

Open WeDev00 opened this issue 1 year ago • 5 comments

despite having the same syntax as in the example, I get the error in the title

`final Web3Provider provider = Web3Provider(ethereum!);

final Signer signer = provider.getSigner();

final Contract contract = Contract(deployedNftContractAddress, tideNftAbiListed, provider);

final symbol = await contract.symbol();`

when running final Web3Provider provider = Web3Provider(ethereum!); I get the error dart.global.ethers is undefined. Below I put all the imports of the file containing this code:

`import 'package:flutter_web3_provider/ethers.dart';

import 'package:http/http.dart' as http;

import 'package:flutter_web3_provider/ethereum.dart';

import 'dart:convert';`

WeDev00 avatar Apr 11 '24 12:04 WeDev00

Did you import ethers like in the example? https://github.com/gochain/flutter_web3_provider/blob/main/example/lib/main.dart

treeder avatar Apr 11 '24 18:04 treeder

yes, as you can see from all the imports i wrote

WeDev00 avatar Apr 11 '24 18:04 WeDev00

Did you add this to the HTML?

<script src="https://cdn.ethers.io/lib/ethers-5.0.umd.min.js" type="application/javascript"></script>

treeder avatar Apr 11 '24 21:04 treeder

I just added it, but I keep getting the same error

WeDev00 avatar Apr 12 '24 07:04 WeDev00

I'm not sure, might have to debug it yourself. Pull Requests are welcome.

treeder avatar Apr 12 '24 15:04 treeder

I solved by downloading and adding manually the script : https://cdn.ethers.io/lib/ethers-5.0.umd.min.js in my project

WeDev00 avatar May 09 '24 21:05 WeDev00