Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
How to bring `op-code` to Hex?

In Blueprint, we will need to write the Wrapper functions ourselves.

More importantly, when we code the op code in our FunC code, we need to decode the string into a Hex op-code and then convert it to the uint and hex data types.

For example:

const op::increase = "op::increase"c; 
;; create an opcode from a string using the "c" prefix; this results in the 0x7e8764ef opcode in this case.

My question is, how can we generalize the process to convert a String into uint and hex data normally?

Posted 11 months ago
Votes Newest


Generally speaking, the FunC code op::increase = "op::increase"c first converts this into a uint (unsigned integer), since in TVM (Turing Virtual Machine), communication is done only in unsigned integers to distinguish the unlimited functions that you build.

On the other hand, the uint can be converted into hex code to save space when storing it in a Smart Contract.

**Here's an example in TypeScript to finalize the op-code into uint and hex data. It uses the CRC32 method to decompress this OP-code information.


const POLYNOMIAL = -306674912;

let crc32_table: Int32Array | undefined = undefined;

export function crc32(str: string, crc = 0xFFFFFFFF) {
    let bytes = Buffer.from(str);
    if (crc32_table === undefined) {
    for (let i = 0; i < bytes.length; ++i)
        crc = crc32_table![(crc ^ bytes[i]) & 0xff] ^ (crc >>> 8);
    return (crc ^ -1) >>> 0;

function calcTable() {
    crc32_table = new Int32Array(256);
    for (let i = 0; i < 256; i++) {
        let r = i;
        for (let bit = 8; bit > 0; --bit)
            r = ((r & 1) ? ((r >>> 1) ^ POLYNOMIAL) : (r >>> 1));
        crc32_table[i] = r;

Once we call the function crc32("deposit"), we can obtain the value 0xb04a29cf in practice.

For more information about the CRC32 method, you can refer to the following links:

Posted 11 months ago
Edited 11 months ago