Skip to content

radianceteam/everscale-client-go

Repository files navigation

TON SDK client Golang

EVER-SDK TON local-node docker image Chat Telegram Documentation CI tests and linters

Preparations

One needs to install

EVER-SDK installation - Mac OS

export EVER_SDK_INSTALLATION_PATH=`pwd`/tmp # example - should be specified as absolute path
# clean previous installation in case of reinstalling
rm -f $EVER_SDK_INSTALLATION_PATH/libton_client.dylib.gz $EVER_SDK_INSTALLATION_PATH/libton_client.dylib
# download binaries
wget https://binaries.tonlabs.io/tonclient_1_darwin.gz -O $EVER_SDK_INSTALLATION_PATH/libton_client.dylib.gz
# extract binaries
gzip -d $EVER_SDK_INSTALLATION_PATH/libton_client.dylib.gz
# make extracted file executable
chmod +x $EVER_SDK_INSTALLATION_PATH/libton_client.dylib
# set loading by absolute path
install_name_tool -id $EVER_SDK_INSTALLATION_PATH/libton_client.dylib $EVER_SDK_INSTALLATION_PATH/libton_client.dylib

# Better to add this to ~/.bashrc or ~/.zshrc to DRY in terminal each time you use it
export CGO_LDFLAGS="-L$EVER_SDK_INSTALLATION_PATH -lton_client"

EVER-SDK installation - Linux

EVER_SDK_INSTALLATION_PATH=`pwd`/tmp # example - should be specified as absolute path
# clean previous installation in case of reinstalling
rm -f $EVER_SDK_INSTALLATION_PATH/libton_client.so.gz $EVER_SDK_INSTALLATION_PATH/libton_client.so
# download binaries
wget https://binaries.tonlabs.io/tonclient_1_linux.gz -O $EVER_SDK_INSTALLATION_PATH/libton_client.so.gz
# extract binaries
gzip -d $EVER_SDK_INSTALLATION_PATH/libton_client.so.gz
# make extracted file executable
chmod +x $EVER_SDK_INSTALLATION_PATH/libton_client.so

# Better to add this to ~/.bashrc or ~/.zshrc to DRY in terminal each time you use it
export LD_LIBRARY_PATH=$EVER_SDK_INSTALLATION_PATH:$LD_LIBRARY_PATH
export CGO_LDFLAGS="-L$EVER_SDK_INSTALLATION_PATH -lton_client"

Run

One needs to specify compiled DLL directory path:

export CGO_LDFLAGS="-L$EVER_SDK_INSTALLATION_PATH -lton_client"
go build ./cmd/cli
go run ./cmd/cli
# or
task run

On Linux one needs to provide search path for DLL loader:

export LD_LIBRARY_PATH=$EVER_SDK_INSTALLATION_PATH:$LD_LIBRARY_PATH

Wrapper usage

For examples see cmd/cli/main.go and run it via go run ./cmd/cli. This wrapper covers 100% of functionality for EVER-SDK. All non-generated code has test coverage at least of 70% - one can see it via task coverage.

Tests

export CGO_LDFLAGS="-L$EVER_SDK_INSTALLATION_PATH -lton_client"
docker run -d --name local-node -p80:80 tonlabs/local-node:0.39.0
task test # tests without node
task full_test # tests including with node
task coverage # full_test with coverage

Development

You need to install:

See available task commands via task without arguments. To attach git hooks run task attach_hooks

Code generation

Most of the code is generated via script in ./cmd/gen/gen.go from spec api-spec.json one can regenerate it via task generate.

Useful reading

Methods and types with manual implementation

See more at spec/types.go

  • processing.send_message
  • processing.wait_for_transaction
  • processing.process_message
  • net.subscribe_collection