diff --git a/src/ext.rs b/src/ext.rs index 319d71d6..3c6e1325 100644 --- a/src/ext.rs +++ b/src/ext.rs @@ -62,6 +62,8 @@ mod external { pub fn gaslimit(dest: *mut u8); + pub fn gasleft() -> i64; + pub fn sender(dest: *mut u8); pub fn address(dest: *mut u8); @@ -253,6 +255,11 @@ pub fn gas_limit() -> U256 { unsafe { fetch_u256(|x| external::gaslimit(x) ) } } +/// Get amount of gas left. +pub fn gas_left() -> u64 { + unsafe { external::gasleft() as u64 } +} + /// Get caller address /// /// This is the address of the account that is directly responsible for this execution.