cvToString
Converts a Clarity value to its Clarity syntax representation as a string.
Usage
import { cvToString, Cl } from '@stacks/transactions';
cvToString(Cl.uint(100));
// 'u100'
cvToString(Cl.bool(true));
// 'true'
cvToString(Cl.some(Cl.uint(100)));
// '(some u100)'
cvToString(Cl.tuple({ a: Cl.uint(1) }));
// '(tuple (a u1))'Notes
For human-readable output with indentation support, use
Cl.stringifyinstead.
Signature
Returns
string
The Clarity syntax string representation.
Parameters
val (required)
Type:
ClarityValue
The Clarity value to convert.
encoding (optional)
Type:
'tryAscii' | 'hex'
For buffer values, controls how bytes are displayed. 'tryAscii' attempts ASCII rendering, 'hex' (default) shows hex.
Last updated
Was this helpful?