-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I got an Error When I Using Sending ETH #242
Labels
duplicate
This issue or pull request already exists
Comments
Duplicate of #239 |
« see in # 239 you said that the code runs without error.» what do you
mean?
This is open and confirmed bug. Most probably it cause by infura api
changes.
On Sun, 16 Feb 2020 at 17:13, haizhiwen ***@***.***> wrote:
let mnemonicstr = "助记词"
let passWord = "password"
let userDir = NSSearchPathForDirectoriesInDomains(.documentDirectory,
.userDomainMask, true)[0]
let bip32ks = try! BIP32Keystore(mnemonics: mnemonicstr, password:
passWord)
let keydata = try! JSONEncoder().encode(bip32ks!.keystoreParams)
FileManager.default.createFile(atPath: userDir +
"/bip32_keystore"+"/key.json", contents: keydata, attributes: nil)
let web3Main = Web3.InfuraMainnetWeb3() //or any other network
let price = "0.0002"
let fromAddress = bip32ks?.addresses?.first?.address
let toAddress = "0xb7c54ABc6Af1862A69fb467C47F54e521CC7c00E"
let destinationEthAddress = EthereumAddress(toAddress)!
let ethAddressFrom = EthereumAddress(fromAddress!)!
let contract = web3Main.contract(Web3Utils.coldWalletABI, at:
destinationEthAddress, abiVersion: 2)
var options = TransactionOptions.defaultOptions
options.from = ethAddressFrom
options.value = Web3Utils.parseToBigUInt(String.init(price),units: .eth)
options.gasPrice = .automatic
options.gasLimit = .automatic
let writeTX = contract!.write("fallback", parameters: [], extraData:
Data.init(), transactionOptions: options)!
writeTX.transactionOptions = options
do {
let sendingResult = try writeTX.send(password: passWord,
transactionOptions: options)
print(sendingResult)
} catch let error {
print("sendingresult error 2")
print(error)
}
This is my code. I executed it directly in didFinishLaunchingWithOptions.
After creating the wallet, I transferred it to toAddress and got error:
typeMismatch (Swift.Array , Swift.DecodingError.Context (codingPath: [],
debugDescription: " Expected to decode Array but found a dictionary
instead. ", UnderlyingError: nil))
What should I do, I see in # 239 you said that the code runs without error.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#242>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZTOOSW3EDTUPNKV5Y5Y5TRDEGWHANCNFSM4KWBVCQA>
.
--
Regards,
Petr Korolev
|
What I said is that some people say that this code works correctly, but I can't do it here. If I run this code, I get an error. |
There is some API changes. The code doesn't work with the latest infura api . We are digging into it. lets move the conversation to the initial issue Closing it in favor of #239 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
let mnemonicstr = "助记词"
let passWord = "password"
let userDir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
let bip32ks = try! BIP32Keystore(mnemonics: mnemonicstr, password: passWord)
let keydata = try! JSONEncoder().encode(bip32ks!.keystoreParams)
FileManager.default.createFile(atPath: userDir + "/bip32_keystore"+"/key.json", contents: keydata, attributes: nil)
let web3Main = Web3.InfuraMainnetWeb3() //or any other network
let price = "0.0002"
let fromAddress = bip32ks?.addresses?.first?.address
let toAddress = "0xb7c54ABc6Af1862A69fb467C47F54e521CC7c00E"
let destinationEthAddress = EthereumAddress(toAddress)!
let ethAddressFrom = EthereumAddress(fromAddress!)!
let contract = web3Main.contract(Web3Utils.coldWalletABI, at: destinationEthAddress, abiVersion: 2)
var options = TransactionOptions.defaultOptions
options.from = ethAddressFrom
options.value = Web3Utils.parseToBigUInt(String.init(price),units: .eth)
options.gasPrice = .automatic
options.gasLimit = .automatic
let writeTX = contract!.write("fallback", parameters: [], extraData: Data.init(), transactionOptions: options)!
writeTX.transactionOptions = options
do {
let sendingResult = try writeTX.send(password: passWord, transactionOptions: options)
print(sendingResult)
} catch let error {
print("sendingresult error 2")
print(error)
}
This is my code. I executed it directly in didFinishLaunchingWithOptions. After creating the wallet, I transferred it to toAddress and got error: typeMismatch (Swift.Array , Swift.DecodingError.Context (codingPath: [], debugDescription: " Expected to decode Array but found a dictionary instead. ", UnderlyingError: nil))
What should I do, I see in # 239 you said that the code runs without error.
The text was updated successfully, but these errors were encountered: