how to decide gas price while writing smart contract ?
There are two things you need to think about:
- When writing your contract: The amount of gas your contract takes;
- When interacting with your contract on the blockchain: The gas price.
You don't decide the gas price when writing the contract, but you want to minimise the price you have to pay when you come to use your contract later on by minimising the gas your contract uses. To do this you need to make your contract as efficient as possible, to ensure it uses the smallest number of EVM instructions possible.
See: What is meant by the term "gas"?
and how to know how much gas is going to be used while each token transaction ?
That depends how on well you have written your contract. An efficient contract will minimise the gas used. (This isn't the same as gas price.)
See: How do I know how much gas to use when calling a contract?
See: How were gas costs chosen for the Ethereum Virtual Machine instructions?
and on https://ethgasstation.info/
mentioned price is SafeLow (<30m) 1 Standard (<5m) 4 Fast (<2m) 20
When you send a transaction, these values give you an estimate of how long that transaction will take for different gas prices. In your example, if you want your transaction to go through quickly, within 2 minutes, you would use the gas price under "Fast". If you're not in a rush, and don't mind waiting up to 30 minutes, you would use the gas price under "SafeLow".
See: Determine network congestion, min required gas/gas price based on current conditions
so is it based on per transaction?