Solidity – Understanding the Difference Between Gas Price and Gas Limit

ethersolidity

What is the exact difference between gas price and gas limit ? And what should be their value? I am reading about smart contracts and these two words are used alot.. need to know what they are and how are they used.

Best Answer

Smart Contracts are written in solidity (a programming language). In smart contracts there is a price of executing each line of code. suppose you wrote 1000 lines of code that code ran and you used 1500 lines (because of loops and conditions) then the gas price will be 1500 whereas gas limit is a limit after which contract will stop executing.

We use gas limit so that if anyhow our contract goes in infinite then it will stop after gas limit reached so that it wont cost us too many ethers.