How to calculate total cost of a transaction

I've a transaction that consumed 276798 of gas, paid 900000000 (wei I think)

Is the total cost gasUsed x gasPrice, right?

Total = 249,118,200,000,000‬ (wei I think)

So how many ether is ?

0.0002491182

Confirm?

Is the total cost gasUsed * gasPrice?

Almost. It's gasUsed * gasPrice + value, where the latter indicates the amount of ether that you have passed (can be larger than 0 when executing a payable function, and must be 0 otherwise).

Total = 249,118,200,000,000‬ (wei I think)

Yes, since both gasPrice and value are in wei, hence both components in the sum (gasUsed * gasPrice and value) are in wei, hence the entire formula (gasUsed * gasPrice + value) is in wei.

So how many ether - 0.0002491182?

• Take 249,118,200,000,000‬
• Remove the commas in order to get 249118200000000‬
• Add 3 zeros on the left in order to get an 18-digit number: 000249118200000000‬
• Add '0.' in order to divide that number by 10^18 and get 0.000249118200000000‬
• Remove all the zeros on the right in order to "clean it up" and get 0.0002491182

So yes, it is 0.0002491182 ether.