string
Pebble 0.3.1 · all symbols on this page are stable.
UTF-8 text. Maps to Plutus Core String. Primarily for logging via trace and for fail messages. Avoid storing large strings on-chain — every character costs CPU/memory in the script budget.
const msg: string = "Order filled";
trace(msg);
Literals
| Form | Example | Notes |
|---|---|---|
| Double-quoted | "hello" | UTF-8. |
| Empty | "" |
Operators
| Category | Operators |
|---|---|
| Equality | ==, != |
| Concatenation | + |
Methods
| Method | Description |
|---|---|
toBytes(): bytes | UTF-8 encode. Equivalent to std.builtins.encodeUtf8. |
To go from bytes back to string, use std.builtins.decodeUtf8 (it fails on invalid UTF-8).
Examples
const greeting: string = "hello";
const u8: bytes = greeting.toBytes(); // #68656c6c6f
// Round-trip:
const back: string = std.builtins.decodeUtf8(u8); // "hello"
// Concatenation and equality:
const full: string = greeting + ", world";
assert full == "hello, world";
See also
std.builtins—appendString,equalsString,encodeUtf8,decodeUtf8std.data—strToData/strFromDataShow— interface every type can implement to produce astringrepresentation