Skip to content

tonwhales/ton-smc-introspection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ton-smc-introspection

This repo contains spec for ton smart contract introspection and reference implementation for JS.

Spec could be found here

Install

yarn add ton-smc-introspection

Usage

genSupportsInterfaceFunction method generates FunC code for basic introspection.

import {genSupportsInterfaceFunction} from 'ton-smc-introspection'

let interfaces = [
    {
        name: 'MathFunctionsInterface',
        declaration: [
            'get-method: int sum(int a, int b)',
            'get-method: int sub(int a, int b)'
        ]
    },
    {
        name: 'ConstantsInterface',
        declaration: [
            'get-method: int get_speed_of_light()'
        ],
        seed: 'random_seed'                         // used to avoid colisions
    }
]

console.log(genSupportsInterfaceFunction(interfaces))

Outputs:

(int, int, int) supported_interfaces() method_id {
    ;; 0x5fd2: MathFunctionsInterface
    ;; 0x2545: ConstantsInterface
    ;; 0x667a: BasicIntrospection
    return (0x5fd2, 0x2545, 0x667a);
}

You can use this function in your FunC smart contract code.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published