Change library
A smart contract can request a change to an account's library collection during the action phase via the change-library action. Any of these instructions can append the change-library action to an out action list:
The change-library action contains:
- a 7-bit
modebitmask specifying the way of changing the library; - a
LibRefvalue containing either a cell reference to the library code or its hash as an unsigned 256-bit integer.
Modes
The mode bitmask supports the following values, with BounceOnFail allowed to be combined with any other value:
| Value | Name | Description |
|---|---|---|
0 | RemoveLibrary | Default mode. Removes a public library if it exists, otherwise does nothing. |
+1 | AddPrivateLibrary | Sets the library status as private. Cannot be combined with AddPublicLibrary (+2). |
+2 | AddPublicLibrary | Sets the library status as public. Cannot be combined with AddPrivateLibrary (+1). |
+16 | BounceOnFail | Bounces the transaction if the action fails. |
Other mode values and their combinations are invalid. Using both AddPrivateLibrary (+1) and AddPublicLibrary (+2) modes at the same time is also invalid and leads to an error.
Limited availability
Since global TVM version 15, the action phase returns exit code 46 on mainnet and testnet when any account uses mode AddPrivateLibrary (+1) or when a regular account requests any library change. Only special masterchain accounts can use base mode 0 or +2 to remove or add public libraries.
The libraries reference page explains how this restriction affects their use.
Serialization
libref_hash$0 lib_hash:bits256 = LibRef;
libref_ref$1 library:^Cell = LibRef;
action_change_library#26fa1dd4
mode:(## 7) libref:LibRef = OutAction;