Skip to content

Libraries

Back to Devpack Overview

Neo.sol (542 lines)

High-level blockchain integration library. Wraps Syscalls and NativeCalls into a convenient API:

CategoryFunctions
Block infogetCurrentBlock(), getBlockByIndex(), getBlockHeight(), getBlockTime()
TransactionsgetTransaction(), getTransactionHeight()
Account/balanceNEO and GAS balance queries via NativeCalls
CryptographicSignature verification, hash functions (delegates to Syscalls CryptoLib)
Contract mgmtCall, deploy, query contracts
NetworkGovernance, committee, validators
GasFee calculations, gas management utilities
solidity
using Neo for *;

(uint256 index, bytes32 hash, uint256 timestamp, bytes32 merkle) = Neo.getCurrentBlock();
uint256 height = Neo.getBlockHeight();

Storage.sol (852 lines)

Advanced storage operations built on top of Syscalls storage syscalls:

CategoryFunctions
ContextgetContext(), getReadOnlyContext(), asReadOnly()
Basic CRUDput(), get(), remove(), exists()
Local storageputLocal(), getLocal(), removeLocal()
Iteratorsfind(), findLocal(), findValues(), findKeys(), findLocalValues(), findLocalKeys()
Countingcount() — count entries matching a prefix
Batch opsBatch put/remove (max 100 per batch)
Key derivationMapping keys, array keys, nested keys
Typed accessorsuint256, address, string, bool typed get/put
Secure storageChecksum validation
ExpirationTTL-based storage entries
solidity
using Storage for *;

// Basic operations
Storage.put("owner", abi.encode(msg.sender));
bytes memory data = Storage.get("owner");
bool hasKey = Storage.exists("owner");

// Iterator-based prefix scan
bytes[] memory allValues = Storage.findValues("token:");
bytes[] memory allKeys = Storage.findKeys("token:");

// Local storage (contract-private, not visible to other contracts)
Storage.putLocal("internal_state", abi.encode(42));

Local vs Global Storage

put()/get() use the contract's global storage context. putLocal()/getLocal() use a local context that is private to the contract and cannot be read by other contracts via System.Storage.GetReadOnlyContext.

Runtime.sol (695 lines)

Runtime services and utilities (currently supported as compiler intrinsics):

CategoryFunctions
Eventsnotify(), notifyIndexed()
WitnesscheckWitness(), requireWitness(), checkAnyWitness(), checkAllWitnesses(), checkMultiSigWitness()
Runtime contextgasLeft(), getTime(), getTrigger(), getInvocationCounter(), getCurrentSigners()
Contract contextgetCallFlags(), getScriptContainer(), loadScript(), getExecutingScriptHash(), getCallingScriptHash(), getEntryScriptHash()
PlatformgetNetwork(), getPlatform(), getAddressVersion(), getRandom()
Logginglog(), burnGas(), initializeServices()
solidity
using Runtime for *;

// Witness verification
bool hasWitness = Runtime.checkWitness(msg.sender);
require(hasWitness, "invalid witness");

// Gas management
uint256 remaining = Runtime.gasLeft();
Runtime.burnGas(1000000); // burn 0.01 GAS

Runtime Intrinsic Coverage

Runtime.sol includes callback-oriented convenience helpers that are not compiler intrinsics in neo-devpack-solidity. Calls to optimizeGasUsage, executeIfGasAvailable, and tryWithFallback are currently rejected at compile time because NeoVM does not support first-class internal function callbacks. Use inline logic (gasLeft guards and try/catch) instead.

MIT Licensed