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.

Unable to send ether using send function

See original GitHub issue

How 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:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
hakumai-iidacommented, Oct 9, 2020

There is another transaction with same nonce in the queue

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)

1reaction
hakumai-iidacommented, Oct 9, 2020

I’m glad your code was working. And i appolgize my reply was crossed.

how to get previous nonce to do next transaction ? like need to increase nonce right so

I think the blockchain will automatically number it, so I don’t think you need to specify it manually.

Read more comments on GitHub >

github_iconTop 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 >

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