लेन-देन भेजने में त्रुटि हो रही है: टाइपत्रुटि: स्पंदन में ब्लॉकचेन ऐप में अपरिभाषित (‘प्रदाताओं’ को पढ़ना) के गुणों को नहीं पढ़ सकता


स्पंदन
  1  import 'package:flutter_web3/flutter_web3.dart';
  2  import 'package:web3dart/web3dart.dart' as web;
  3  import 'package:web3dart/credentials.dart';
  4  
  5  String currentAddress = '';
  6  bool get isEnabled = ethereum != null;
  7  bool get isConnected =isEnabled && currentAddress.isNotEmpty;
  8  
  9  Future<bool> sendTransaction({required EthereumAddress to}) async {
 10      if (isEnabled) {
 11          final accs = await ethereum!.requestAccount();
 12          if (accs.isNotEmpty)
 13              currentAddress = accs.first; //assign current address to first address
 14          if (currentAddress != '') {
 15              print(currentAddress);
 16          }
 17      }
 18      if (!isConnected) {
 19          return false;
 20      }
 21      try {
 22          final eth = Ethereum.ethereum;
 23          final transaction = web.Transaction(
 24              from: EthereumAddress.fromHex(currentAddress),
 25              to: to,
 26              value: web.EtherAmount.inWei(BigInt.parse("8000")),
 27          );
 28          if (ethereum != null) {
 29              print("Etherem is not null");
 30          }
 31  
 32          final web3provider = Web3Provider(ethereum!);
 33          final signer = provider?.getSigner();
 34          final tx = await signer?.sendTransaction(transaction as TransactionRequest);
 35  
 36          if (tx != null) {
 37              print(tx.hashCode);
 38              return true;
 39          }
 40  
 41          print("Transaction is not performed");
 42          return false;
 43      } catch (e) {
 44          print("Errror sending transaction : $e");
 45          return false;
 46      }
 47  }

मैंने क्या प्रयास किया है:

क्रोम (मेटामास्क एक्सटेंशन) में इस कोड को चलाने के दौरान, मेटामास्क खाते से जुड़ने के लिए पॉपअप होगा लेकिन उसके बाद यह टाइप एरर देता है: अपरिभाषित गुणों को नहीं पढ़ सकता (‘प्रदाताओं’ को पढ़ना), मेरा मानना ​​​​है कि त्रुटि है, अंतिम वेब3प्रोवाइडर = वेब3प्रोवाइडर(एथेरियम! ); लेकिन मुझे नहीं पता कि इसका समाधान क्यों और कैसे किया जाए।

समाधान 1

संदेश “अपरिभाषित के गुणों को नहीं पढ़ सकता” एक ऐसी वस्तु का उपयोग करने का प्रयास करने के लिए जावास्क्रिप्ट-ese है जो मौजूद नहीं है, या अन्य भाषा में शून्य है।

मुझे आपके द्वारा पोस्ट किए गए कोड में कहीं भी “प्रदाता” संपत्ति या विधि को कॉल करते हुए नहीं देखा गया है, तो इसका मतलब है कि त्रुटि संभवतः उस लाइब्रेरी द्वारा फेंकी जा रही है जिसका आप उपयोग करने का प्रयास कर रहे हैं। एकमात्र लोग जो इसमें आपकी सहायता कर सकते हैं वे वे लोग हैं जिन्होंने लाइब्रेरी लिखी है।

コメント

タイトルとURLをコピーしました