Functions & calls

Gas

NEAR meters gas too, but measured in gas units (Tgas), paid by the caller, and attached explicitly to cross-contract calls.

Both chains meter execution as gas. The differences: NEAR gas is a unit of compute (1 Tgas = 10¹² gas), its price is far more stable, and when you make a cross-contract call you attach a gas budget to it explicitly rather than forwarding whatever is left.

Reading the gas context
Solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

contract GasInfo {
    // remaining gas for this call
    function remaining() external view returns (uint256) {
        return gasleft();
    }
}
Rust
use near_sdk::{near, env};

#[near(contract_state)]
#[derive(Default)]
pub struct GasInfo {}

#[near]
impl GasInfo {
    // gas attached to this call, and gas burnt so far (in gas units)
    pub fn prepaid(&self) -> u64 {
        env::prepaid_gas().as_gas()
    }

    pub fn used(&self) -> u64 {
        env::used_gas().as_gas()
    }
}
Coming from EVM

gasleft() ≈ env::prepaid_gas() - env::used_gas(). Gas is a Gas type; Gas::from_tgas(5) builds 5 Tgas and .as_gas() reads the raw units.

A single transaction can attach up to 300 Tgas. When you schedule a cross-contract call you carve out part of that budget with .with_static_gas(Gas::from_tgas(n)) — unlike Solidity, the callee does not just inherit the remaining gas.

Fees are paid by the signer in NEAR and are refunded for any unused gas. There is no gasprice auction in the EVM sense — the price is a protocol-set value that moves slowly.