Boilertalk / Web3.swift

A pure swift Ethereum Web3 library
MIT License
639 stars 188 forks source link

someone please let me know gas: 1500000 = ??? ETH #112

Closed tungnguyentp closed 1 year ago

tungnguyentp commented 2 years ago

guard let transaction = contract["createToken"]?(nftUrl).createTransaction(nonce: nonce, from: myPrivateKey!.address, value: 0, gas: 1500000, gasPrice: EthereumQuantity(quantity: 200.gwei)) else { print("error") self.alert.dismiss(animated: true, completion: nil) self.showAlert(title: "Error", message: "An error has occurred.") return }

-> someone please let me know gas: 1500000 = ??? ETH . What is the conversion formula?

Florian-S-A-W commented 1 year ago

Gas is calculated by multiplying the gas limit with the gas price. Since the London upgrade you have to pay a base fee and can pay a priority fee. One gwei is 10^-9 ETH. In your example the total price would be 1.500.000 200 10^-9 = 0.3 ETH https://ethereum.org/en/developers/docs/gas/

I usually use this converter: https://eth-converter.com/