Previous Versions#
Note
Verified against node-scala commit 104ddc70e8. The functions, types and variables each version adds or removes come from the dump the function reference is generated from. Every compile error quoted below was reproduced on the Testnet node’s POST /utils/script/compileCode.
The function reference covers versions 6 to 9, and the hand-written function and structure pages describe version 5. This page covers versions 1 to 5: which of them a network still accepts, what each one added, and what breaks when you move a script to a newer version.
Which Versions a Network Accepts#
A script always runs with the standard library version it was compiled for. A node upgrade or a feature activation never changes how an existing script evaluates. To use a newer version, recompile the script and set it again.
A new script is checked when a Set Script, Set Asset Script or Issue transaction carries it:
Versions 3 and later need the blockchain feature listed under Standard Library Versions.
Versions 1 and 2 need no feature of their own.
From feature 22 (Light Node), versions 1 to 3 are rejected. The node refuses any new script below version 4 with
Script version below V4 is not allowed after Light Node feature activation. Scripts already on the chain keep running.
Network |
Highest active feature |
Versions accepted for a new script |
|---|---|---|
Testnet |
26 |
4 to 9 |
Mainnet |
16 |
1 to 5 |
Always write the STDLIB_VERSION directive. Without it, the compiler library assumes version 3, while the node’s /utils/script/compileCode endpoint assumes version 5 on both networks, because feature 16 is active on both. The same source can therefore compile to two different scripts.
What Each Version Added#
Limits that change between versions, such as complexity, payments and script actions, are on Limitations.
Version 1#
Account scripts and asset scripts, both CONTENT_TYPE EXPRESSION: a Boolean expression that allows or denies a transaction. There are no dApps. The library has 62 functions and operators: arithmetic and comparison, sigVerify and the sha256, keccak256 and blake2b256 hashes, Base58 and Base64 conversion, account data reads (getInteger(address, key) and the like), dccBalance, assetBalance, transactionById and extract. The global variables are tx, height, unit and the rounding modes CEILING, DOWN, FLOOR, HALFDOWN, HALFEVEN, HALFUP and UP.
Version 2#
The same functions and types as version 1, plus the Buy and Sell order-direction variables.
Version 3#
dApps.
CONTENT_TYPE DAPPscripts with@Callableand@Verifierfunctions. A callable returns aWriteSetofDataEntryvalues, aTransferSetofScriptTransfervalues, or both in aScriptResult. It receives at most one payment, asi.payment. Callable arguments can beInt,String,ByteVectororBoolean.New variables:
this,lastBlock,nil, and the RSA digest algorithmsNOALG,MD5,SHA1,SHA224,SHA256,SHA384,SHA512,SHA3224,SHA3256,SHA3384andSHA3512.New types:
Invocation,AttachedPayment,BlockInfo,AssetandInvokeScriptTransaction.New functions:
addressFromStringValue,assetInfo,blockInfoByHeight,checkMerkleProof,cons,fromBase16String,toBase16String,getBinaryValue,getBooleanValue,getIntegerValue,getStringValue,indexOf,lastIndexOf,split,parseInt,parseIntValue,toInt,toUtf8String,log,pow,rsaVerify,transferTransactionById,valueandvalueOrErrorMessage.Removed:
transactionById. UsetransferTransactionById, which reads only Transfer transactions.
Version 4#
Callables return a list of actions instead of
WriteSet,TransferSetorScriptResult, which are removed together withDataEntry. The actions areBinaryEntry,BooleanEntry,IntegerEntry,StringEntry,DeleteEntry,ScriptTransfer,Issue,Reissue,BurnandSponsorFee.Payments and arguments. An invocation carries up to 2 payments, as the list
i.payments. Callable arguments can also be lists of the four primitive types.New types:
BalanceDetailsandUpdateAssetInfoTransaction.New list functions: the
++and:+operators,containsElement,indexOfandlastIndexOfon lists,max,min,median,removeByIndexandmakeString.New verification functions:
createMerkleRoot,ecrecover, andgroth16Verifyandbn256Groth16Verify, each with_1inputsto_15inputsvariants. Size-capped variants of the hashes and verifiers, such assha256_16KbandsigVerify_8Kb, cost less than the uncapped ones.Other new functions:
contains,valueOrElse,calculateAssetIdandtransferTransactionFromProto. ThegetInteger(data, key)family that reads a list of data entries now takes the typed entries instead ofDataEntry.Removed:
extract(usevalue) andcheckMerkleProof(usecreateMerkleRoot).Data keys can be up to 400 bytes instead of 100, and can no longer be empty.
Version 5#
dApp-to-dApp invocations with
invokeandreentrantInvoke, available in dApp scripts only. See dApp-to-App Invocation. A callable can return a tuple of its actions and a value for the caller.BigInt. The type,toBigInt,parseBigIntandparseBigIntValue, andBigIntoverloads of the arithmetic operators and offraction,pow,log,median,min,max,toBytes,toIntandtoString.Leasing actions
LeaseandLeaseCancel, withcalculateLeaseId.Own-account data reads.
getInteger(key),getString(key)and the rest of that family read the script’s own account without an address. They aren’t available in asset scripts.Other new functions:
isDataStorageUntouchedandscriptHash.Payments: up to 10 per invocation.
Removed: the
HALFDOWNandUProunding modes.CEILING,DOWN,FLOOR,HALFEVENandHALFUPremain.
Upgrading a Script#
The compiler rejects these constructs once you raise STDLIB_VERSION past the version shown. Each row has been compiled on both sides of the boundary.
From |
To |
What breaks |
Compile error |
Fix |
|---|---|---|---|---|
1–2 |
3 |
|
|
|
3 |
4 |
|
|
Return a list of actions; use |
3 |
4 |
|
|
|
3 |
4 |
|
|
|
3 |
4 |
|
|
|
4 |
5 |
|
|
Another rounding mode |
5 |
6 |
A union type as a |
|
One argument per type, or a |
7 |
8 |
|
|
Rename; both are keywords from version 8 |
7 |
8 |
An object pattern with no fields, such as |
|
Match on the type: |
7 |
8 |
A non-constant field pattern, such as |
|
Bind the field and compare it in the case body |
Version 3 could not take a list as a callable argument: List[Int] fails with Unexpected callable func arg type: List[Int]. That is a restriction lifted by version 4, not a break.
Raising the version can also change costs without changing any code. Some functions get cheaper (split goes from 75 to 1 at version 6), and a few get more expensive (pow on BigInt goes from 200 to 270). Check the script’s new total against Complexity Changes by Version.