Skip to content

shuva10v/contracts-executor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contract executor HTTP API

Simple wrapper around @ton/sandbox. Starts an HTTP server with POST /execute method:

{
    "code": "te6cckECDQEA...", # base64 encoded code cell
    "data": "te6cckECDQEA...", # base64 encoded data cell
    "method": "get_data", # get-method data,
    "arguments": [], # get-method arguments
    "address": "EQ...", # contract address
    "expected": ["int", "int", "address", "metadata", "cell_hash"], # method signature
    "parse_list": true # parse output as a lisp-style list
}

expected field should contain a list of expected value types for the method being executed. It is required to format returned value from internal representation to some meaningful form. Supported types:

  • int - converts BN to number (returned as string, not int)
  • address - reads address from slice and converts to friendly format (EQ..)
  • cell_hash - computes Cell hash
  • boc - returns base64 representation of cell
  • string - returns string representation of slice
  • metadata - reads TEP-64 metadata

Returns list of results

{
    "exit_code": 0,
    "gasUsed": 685,
    "result": [
        12312321,
        -1,
        "EQ_________________________________1",
        {
            "content_layout": "on-chain",
            "content": {
                "name": "Name",
                "symbol": "Symbol"
            }
        },
        "zScFSDDDSN1XMaS2UzYDDDejOtgpJSFpCK0sh8VDKUo="
    ],
    .... // some other debug stuff
}

Master chain libs support

If the contract uses masterchain libs executor will detect it and will try to request it using dton.io. To avoid repeatedly requests one could use caching by providing LIBRARY_CACHE env with the cache file name like this:

LIBRARY_CACHE=mc_libs.txt node executor.js 

About

TON contracts executor API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published