Send ETH on Kovan Testnet error:Swift.DecodingError.typeMismatch...
See original GitHub issueError: 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:
- Created 2 years ago
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Update, fixed with:
self.web3.addKeystoreManager(keystoreManager)
@BitSigOrg thanks for the update.
So probably we have to specify it clearly in the readme, @Iysbaera