question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Send ETH on Kovan Testnet error:Swift.DecodingError.typeMismatch...

See original GitHub issue

Error: Fatal error: ‘try!’ expression unexpectedly raised an error: Swift.DecodingError.typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: “Expected to decode Array<Any> but found a dictionary instead.”, underlyingError: nil))

My Code:

func sendETHOnTestnet() {
        let password = "web3swift"
        let privateKey = "XXX"
        let formattedKey = privateKey.trimmingCharacters(in: .whitespacesAndNewlines)
        let dataKey = Data.fromHex(formattedKey)!
        let keystore = try! EthereumKeystoreV3(privateKey: dataKey, password: password)
        let keystoreManager = KeystoreManager([keystore! as EthereumKeystoreV3])
        print(keystoreManager.addresses!)
        
        let endpoint = "https://kovan.infura.io/v3/XXX"
        let web3 = try! Web3.new(URL(string: endpoint)!)
        
        let value = "0.001"
        let amount = Web3.Utils.parseToBigUInt(value, units: .eth)
        let walletAddress = keystore?.addresses?.first!
        let toAddress = EthereumAddress("0x50bc2c973adf4b0071ac85c23beb646e5288c1b5")!
        
        let contract = web3.contract(Web3.Utils.coldWalletABI, at: toAddress, abiVersion: 2)!
        var options = TransactionOptions.defaultOptions
        options.value = amount
        options.from = walletAddress
        options.gasPrice = .automatic
        options.gasLimit = .automatic
        let tx = contract.write("fallback", parameters: [AnyObject](), extraData: Data(), transactionOptions: options)!
        
        let result = try! tx.send(password: password)
        print(result)
        print(result.hash)
        print("----------")
    }

From Usage ‘Send Transaction’: https://github.com/skywinder/web3swift/blob/master/Documentation/Usage.md#web3-instance

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
BitSigOrgcommented, Jul 3, 2021

Update, fixed with: self.web3.addKeystoreManager(keystoreManager)

0reactions
skywindercommented, Jul 31, 2021

@BitSigOrg thanks for the update.

So probably we have to specify it clearly in the readme, @Iysbaera

Read more comments on GitHub >

github_iconTop Results From Across the Web

Withdraw ETH sometimes fails with ERROR 5 on Kovan #243
Regarding depositWTH/withdrawETH of aave, I've faced to an issue. Withdraw is failed with error 5 (VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE) ...
Read more >
Cannot obtain Kovan testnet Ether - Ethereum Stack Exchange
I need KETH to debug issues with running a personal project that works locally. Happy to pay (nominal amounts) for KETH as obtaining...
Read more >
The beginners guide to using GoodGhosting on Kovan testnet
Select Kovan Test Network · Paste in your ETH address from MetaMask, and click on the button. · Example view of the early...
Read more >
Deploying blockchain transaction to Kovan testnet via web3 ...
Error by deploying transaction Error: Returned error: Insufficient funds. The account you tried to send transaction from does not have enough ...
Read more >
kovan-testnet/faucet - Gitter
I am just helping spreading a minimum amount to help dev get started. with 10 ETH you can already send a fat amount...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found