This repository stores common contracts made by Deplant.
Library with common functions (only internal and mostly inlined), modifiers, constants, rules and strategies.
Gas Management - abstract contract with internal functions & modifiers for gas management strategy where you always reserve a certain amount of gas on your contract and return all EVERs above this floor to contract's counterparties.
Contract has one virtual
function $gasFloor()
that you need
to override
like this:
function $gasFloor() override internal inline view returns (uint128 gasAmount) {
return DEFAULT_GAS_FLOOR;
}
DEFAULT_GAS_FLOOR is 25000 gas. You can specify your own value for floor. All functions and modifiers will use this gas floor.
Typical usage of modifiers is:
function publishCustomTask() external view internalMsg reserveGas returnAllUnreserved {
// reserveGas() modifier will reserve gas floor at the beginning
// returnAllUnreserved() modifier will return all extra gas to sender at the end
}
address _owner;
function publishCustomTask() external view internalMsg reserveGasExactly(25_000) returnAllUnreservedTo(_ownerAddress) {
// reserveGasExactly(25_000) modifier will reserve 25000 gas as a floor
// returnAllUnreservedTo(_ownerAddress) modifier will return all extra gas to address variable _owner
}
Abstract contracts to help with ownership management.
- Externally Owned - common modifiers for externally-owned contract
- Internally Owned - common modifier for internally-owned contracts
Math Library contains a lot of useful Solidity math (sorts, averages, price convertations), still, it's not final and not for everyone, so use it as a copy/paste source.
These are constants that are used by everyone & everywhere:
- Errors - common exception constants for almost any contract
- Flags - common flag constants for message transfers & gas reserve
Address Type Extension contains various useful functions for extending Address type.
TvmCell Type Extension contains various useful functions for extending TvmCell type.