发送BNB币时,它抛出错误nodeError(desc: “unknown account”) ios swift

While Sending BNB Coin it throws error nodeError(desc: "unknown account") ios swift

提问人:Gareja Kirit 提问时间:7/25/2023 最后编辑:Gareja Kirit 更新时间:7/25/2023 访问量:38

问:

我用来发送 bnb 的函数

我有来自UserDefault的当前用户钱包地址 来自文本字段的接收者用户钱包地址 来自文本字段的金额

我正在发送选项

我用来发送 bnb 的函数

我有来自UserDefault的当前用户钱包地址 来自文本字段的接收者用户钱包地址 来自文本字段的金额

我正在发送选项

let result = try tx.send(password: “”) 此行抛出错误 nodeError(desc: “unknown account”) 错误

func transferETH()
{
    let strETHAmount: String = trimString(trimstr: txtTransferAmount.text!)
    let strReceiverWalletAddress: String = trimString(trimstr: txtReceiveAddress.text!)

        if strETHAmount.count == 0 {
            AppDelegate.sharedAppDelegate().hideLoadingView()
            return
        }
        if strReceiverWalletAddress.count == 0 {
            AppDelegate.sharedAppDelegate().hideLoadingView()
            return
        }
        
        if let myaddress = Defaults(key: DefaultsKeys.USER_DEFAULT_WALLET_ADDRESS) as? String {
            
            let walletAddress = EthereumAddress(myaddress)! // Your wallet address
            let toAddress = EthereumAddress(strReceiverWalletAddress)! // Receiver wallet address
            
            let contract = web3Obj.contract(Web3.Utils.coldWalletABI, at: toAddress, abiVersion: 2)!
            let amount = Web3.Utils.parseToBigUInt(strETHAmount, units: .eth)
            
            
            print("amount",amount!)
            
            var options = TransactionOptions.defaultOptions
            options.value = amount
          //  options.to = toAddress
            options.from = walletAddress
            options.gasPrice = .automatic
            options.gasLimit = .automatic
            let tx = contract.write(
                "fallback",
                parameters: [AnyObject](),
                extraData: Data(),
                transactionOptions: options)!
            
            print("txtxtxtxtxtx:",tx)
            
            do {
                
                let result = try tx.send(password: "")
                print("result.hash:",result.hash)
                
                AppDelegate.sharedAppDelegate().hideLoadingView()
                showAlertHandlerDefaultApple(title: String.str_alert_validation_title, message: String.str_transaction_successfully_done, view: self) { action in
                    DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
                        print("yes")
                        self.dismiss(animated: true, completion: nil)
                    }
                }
                
                
            } catch {
                AppDelegate.sharedAppDelegate().hideLoadingView()
                print("**** Error :",error)
            }
        }else{
            AppDelegate.sharedAppDelegate().hideLoadingView()
        }
    }

就说这有什么问题

这是期权数据,这里有什么问题

EthereumContract(transactionOptions: 可选(web3swift.TransactionOptions(type: Optional(Legacy),

to:可选(web3swift.EthereumAddress(_address: “0x6378398dec8e7f3419c501919c1d2fdadcbb46fb”,类型:web3swift。EthereumAddress.AddressType.normal)),

from: 可选(web3swift.EthereumAddress(_address: “0xe507be01aa9c0863ab89170c632da43c21c79ad1”,类型:web3swift。EthereumAddress.AddressType.normal)),

chainID:无,

gasLimit: 可选(web3swift.TransactionOptions.GasLimitPolicy.automatic)、

gasPrice:可选(web3swift.TransactionOptions.GasPricePolicy.automatic)、

maxFeePerGas:可选(web3swift.TransactionOptions.FeePerGasPolicy.automatic)、

maxPriorityFeePerGas:可选(web3swift.TransactionOptions.FeePerGasPolicy.automatic)、

value: 可选 (100000000000000000),

nonce: 可选(web3swift.TransactionOptions.NoncePolicy.pending)、TransactionOptions.NoncePolicy.pending)、

callOnBlock:可选(web3swift.TransactionOptions.CallingBlockPolicy.pending), accessList: nil)),

address: 可选(web3swift.EthereumAddress(_address: “0x6378398dec8e7f3419c501919c1d2fdadcbb46fb”,类型:web3swift。EthereumAddress.AddressType.normal)),

_abi:[web3swift。阿比。Element.fallback(web3swift.阿比。Element.Fallback(常量:false,payable:true))])

iOS Swift 错误处理 加密

评论

0赞 Joakim Danielson 7/25/2023
你的代码到底出了什么问题,在哪一行?是运行时错误还是响应中的错误?你的问题很清楚,所以要努力改进它。
0赞 Joakim Danielson 7/25/2023
编辑您的问题,而不是将其作为评论发布。
0赞 Joakim Danielson 7/25/2023
不,当然不是,那么我会发布解决方案。
0赞 Gareja Kirit 7/25/2023
Joakim Danielson 我添加了我附加的期权数据,他们有什么问题吗?
0赞 Joakim Danielson 7/25/2023
我以一般的方式评论了你的问题,因为我相信它可以改进。我对api一无所知。不好意思。

答: 暂无答案