Sending ETH always results in zero value
See original GitHub issueHi there, I am having a problem sending ether to another account.
The transaction works and is confirmed, however, the resulting value is always set to 0.
Here I prepare the write tx:
func prepareSendEthTx(toAddress: String,
value: String,
gasLimit: TransactionOptions.GasLimitPolicy = .automatic,
gasPrice: TransactionOptions.GasPricePolicy = .automatic) throws -> WriteTransaction {
guard let ethAddress = EthereumAddress(toAddress) else {
throw Web3Error.dataError
}
guard let contract = Keys.shared.web3.contract(Web3.Utils.coldWalletABI, at: ethAddress, abiVersion: 2) else {
throw Web3Error.dataError
}
guard let amount = Web3.Utils.parseToBigUInt(value, units: .eth) else {
throw AccountError.unexpectedError
}
var options = TransactionOptions()
options.from = Keys.shared.manager?.addresses?.first
options.value = amount
options.gasPrice = gasPrice
options.gasLimit = gasLimit
guard let tx = contract.write("fallback",
parameters: [AnyObject](),
extraData: Data(),
transactionOptions: options) else {
throw Web3Error.transactionSerializationError
}
return tx
}
Everything looks fine. This is the TransactionOptions object:
TransactionOptions(
to: Optional(EthereumAddress.EthereumAddress(_address: "0xfc414becae6d7501d8d21080000b7f0c6ddc0319", type: EthereumAddress.EthereumAddress.AddressType.normal)),
from: Optional(EthereumAddress.EthereumAddress(_address: "0xa7bc374704a8c6fa4c5445f593c6b3f93d38388b", type: EthereumAddress.EthereumAddress.AddressType.normal)),
gasLimit: Optional(Web3swift.TransactionOptions.GasLimitPolicy.automatic),
gasPrice: Optional(Web3swift.TransactionOptions.GasPricePolicy.automatic),
value: Optional(1110000000000000),
nonce: Optional(Web3swift.TransactionOptions.NoncePolicy.pending),
callOnBlock: Optional(Web3swift.TransactionOptions.CallingBlockPolicy.pending))
Notice how the value is set to Optional(1110000000000000)
Then I send the tx:
func sendTx(transaction: WriteTransaction,
options: TransactionOptions? = nil,
password: String) throws -> TransactionSendingResult {
do {
let txOptions = options ?? transaction.transactionOptions
let result = try transaction.send(password: password, transactionOptions: txOptions)
return result
} catch let error {
throw error
}
}
The transaction goes through and this is the result:
TransactionSendingResult(transaction: Transaction
Nonce: 6
Gas price: 1000000000
Gas limit: 21000
To: 0xFC414bECAe6d7501D8D21080000B7F0c6DDc0319
Value: 0
Data: 0x
v: 42
r: 5929458399957725041400216354341598697667867491459569312379643997479227879803
s: 46684624884338268292064988579207285325981713662687541280814821577712237382388
Intrinsic chainID: Optional(3)
Infered chainID: Optional(3)
sender: Optional("0xA7Bc374704A8C6Fa4c5445f593c6B3F93D38388b")
hash: Optional("0x9c9e688f298a444d656fadb1d9b7187e6504d5365834ca073c2d28a3e74fc158")
, hash: "0x9c9e688f298a444d656fadb1d9b7187e6504d5365834ca073c2d28a3e74fc158")
For some reason, the resulting value is zero. Any ideas??
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (2 by maintainers)
Top Results From Across the Web
Sending ETH always results in zero value · Issue #149 - GitHub
Hi there, I am having a problem sending ether to another account. The transaction works and is confirmed, however, the resulting value is...
Read more >Does a token-transfer always have a value of zero?
Yes, usually the token contract will reject a transfer with a non zero value. For a contract method to ...
Read more >Why does the blockchain show a zero Value? : Help Center
The Value shows as 0 Ether, however the summary above that shows the entire transaction clearly shows that 1 Ether was sent to...
Read more >Send a transaction from Zero Address - ethereum
I was wondering if it is ever possible to sign and send a transaction using the zero address. Only if you hold the...
Read more >Decoding an Ethereum Transaction.
This, we assume, is how much value needs to be transferred from the Gnosis safe. It's value is zero. The next parameter is...
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
Fixed this bug. Fix will be in new version with Websockets
hi, how are you ?
I have the next issue sending de transaction…
po try tx?.send(password: password, transactionOptions: options) ▿ DecodingError ▿ typeMismatch : 2 elements - .0 : Swift.Array<Any> ▿ .1 : Context - codingPath : 0 elements - debugDescription : “Expected to decode Array<Any> but found a dictionary instead.” - underlyingError : nil
I did all the same @barrasso… I am using spm