Stamps

Stamps #

A stamp is a single unit of computational work in a smart contract. Stamps are converted from cryptocurrency on the main Lamden network. This is what enforces rate limiting and incentivizes the development of the network.

To calculate work, the code is ran through an optimized tracer. Each Python VM opcode has a specific cost. Each step of the code deducts from the number of stamps attached to the transaction.

If all of the stamps are deducted before the transaction is done, the transaction reverts states and fails. If there are left over stamps from the transaction execution, they are returned to the sender.

Read Write Costs #

  • Cost to read one byte from state: 3 stamps
  • Cost to write one byte to state: 25 stamps

Opcode Cost Chart #

Details on Python Opcodes from the dis module documentation here. CPython Opcode definitions here.

Some opcodes that are never encountered due to the linter failing the contract on submission have been left out of this table. Inversely, not all opcodes in this list may ever be encountered in valid Contracting code.

Op CodeNumCostMuliplierActual Cost
POP_TOP1122
ROT_TWO2224
ROT_THREE32.525
DUP_TOP4122
DUP_TOP_TWO5224
NOP9122
UNARY_POSITIVE10122
UNARY_NEGATIVE111.523
UNARY_NOT12122
UNARY_INVERT15224
BINARY_POWER1915230
BINARY_MULTIPLY201.523
BINARY_MODULO22224
BINARY_ADD231.523
BINARY_SUBTRACT241.523
BINARY_SUBSCR251.523
BINARY_FLOOR_DIVIDE26224
BINARY_TRUE_DIVIDE27224
INPLACE_FLOOR_DIVIDE28224
INPLACE_TRUE_DIVIDE292.525
INPLACE_ADD552.525
INPLACE_SUBTRACT562.525
INPLACE_MULTIPLY57224
INPLACE_MODULO59224
STORE_SUBSCR60224
DELETE_SUBSCR61224
BINARY_LSHIFT62326
BINARY_RSHIFT63326
BINARY_AND64326
BINARY_XOR65326
BINARY_OR66326
INPLACE_POWER6715230
GET_ITER683.527
GET_YIELD_FROM_ITER696212
LOAD_BUILD_CLASS7180521610
INPLACE_LSHIFT75326
INPLACE_RSHIFT76326
INPLACE_AND77326
INPLACE_XOR78326
INPLACE_OR79326
BREAK_LOOP80122
WITH_CLEANUP_START817.5215
WITH_CLEANUP_FINISH827.5215
RETURN_VALUE83122
IMPORT_STAR84632126
SETUP_ANNOTATIONS8550021000
POP_BLOCK87224
END_FINALLY88224
POP_EXCEPT89224
STORE_NAME90122
DELETE_NAME91122
UNPACK_SEQUENCE92428
FOR_ITER93428
UNPACK_EX94122
STORE_ATTR95326
DELETE_ATTR96326
STORE_GLOBAL97224
DELETE_GLOBAL98224
LOAD_CONST100122
LOAD_NAME101122
BUILD_TUPLE102122
BUILD_LIST1032.525
BUILD_SET104428
BUILD_MAP1053.527
LOAD_ATTR106224
COMPARE_OP107224
IMPORT_NAME10819238
IMPORT_FROM109632126
JUMP_FORWARD110224
JUMP_IF_FALSE_OR_POP111224
JUMP_IF_TRUE_OR_POP112224
JUMP_ABSOLUTE113224
POP_JUMP_IF_FALSE114224
POP_JUMP_IF_TRUE115224
LOAD_GLOBAL1161.523
CONTINUE_LOOP119122
SETUP_LOOP120224
SETUP_EXCEPT121122
SETUP_FINALLY1221.523
LOAD_FAST124122
STORE_FAST125122
DELETE_FAST126122
STORE_ANNOTATION12750021000
RAISE_VARARGS1302.525
CALL_method1314.529
MAKE_method1323.527
BUILD_SLICE1336212
LOAD_CLOSURE1353.527
LOAD_DEREF136122
STORE_DEREF137122
DELETE_DEREF138122
CALL_method_KW1416212
CALL_method_EX1426212
SETUP_WITH1437.5215
LIST_APPEND145428
SET_ADD146428
MAP_ADD1472.525
LOAD_CLASSDEREF148122
EXTENDED_ARG144122
BUILD_LIST_UNPACK1492.525
BUILD_MAP_UNPACK1503.527
BUILD_MAP_UNPACK_WITH_CALL1514.529
BUILD_TUPLE_UNPACK152122
BUILD_SET_UNPACK153428
FORMAT_VALUE15515230
BUILD_CONST_KEY_MAP1563.527
BUILD_STRING157428
BUILD_TUPLE_UNPACK_WITH_CALL158224

Updated on February 3, 2021