Unable to send ether using send function
See original GitHub issueHow to send ether using below code
its skipping at - transaction.send(password: password)
let value: String = "1.0" // In Ether
let walletAddress = EthereumAddress(wallet.address)! // Your wallet address
let toAddress = EthereumAddress(toAddressString)!
let contract = web3.contract(Web3.Utils.coldWalletABI, at: toAddress, abiVersion: 2)!
let amount = Web3.Utils.parseToBigUInt(value, units: .eth)
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 password = "web3swift"
let result = try! transaction.send(password: password)
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Unable to send ether to contract - Ethereum Stack Exchange
You can send ether to the contract by using the buy function (instead of the fallback function). Example: ethereum.stackexchange.com/questions/ ...
Read more >Unable to send ether to contract - Stack Overflow
I am new to Solidity, I am trying to build a simple smart contract and explore solidity in the process.
Read more >Sending Ether (transfer, send, call) | Solidity by Example | 0.8.17
How to receive Ether? A contract receiving Ether must have at least one of the functions below. receive() external payable; fallback() external payable....
Read more >Secure Ether Transfer | solidity-patterns - GitHub Pages
you want to transfer ether from a contract address to another address in a secure ... { //handle failed send } } function...
Read more >Recommendations for Smart Contract Security in Solidity
If you wish to be able to receive Ether from a .send() or .transfer() , the most you can do in a fallback...
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
I think you got this error because you issued a new transaction before the transaction was processed(A nonce is like a transaction processing number).
If the gas price is too low, the transaction will be pending and will not be processed at worst. Try a larger gas price.
Let’s review the terms.
1.GAS is a unit price to exec something on EVM. ex) “ADD” op-code takes 3 GAS.
2.GAS PRICE is the price of Ethereum for 1 GAS, and the value considers gwei as the unit price. (gwei = GIGA wei = 1,000,000,000 wei)
ex) if you apply gas price as 10gwei, “ADD” op-code wastes 3*10gwei.
3.GAS LIMIT is the maximum amount of GAS that you can consume during a transaction, and the default value is 21,000
ex) if the gas limit is 21,000, “ADD” op-code can be processed 7,000 times.
As a test i tried the codes on kovan with “.automatic”, the gas price was “11000000000”. So kovan network recommends 11gwei for the gas price.
Also i tried “9000000000”(9gwei), the transakuction was processed.
I hope this helps. (I’m sorry for strange English)
I’m glad your code was working. And i appolgize my reply was crossed.
I think the blockchain will automatically number it, so I don’t think you need to specify it manually.