A set of command-line tools for interacting with a trustless bridge in the TON blockchain. This project includes utilities for fetching, processing, and verifying blockchain data.
- Fetch Block: Retrieves a block from the blockchain.
- Prune Block: Removes unnecessary data from a block.
- Block Proof: Generates a proof from one block to another.
- Block Signatures: Extracts block signatures.
- Transaction Proof: Constructs a proof for a transaction.
- Deploy Contracts: Deploy contracts using the
deploy
command. - Send Check Transaction: Sends a
check_transaction
message to verify transactions. - Send New Key Block: Sends a
new_key_block
message to a LiteClient. - Send Check Block: Sends a
check_block
message to verify a block.
By default, the utilities look for a configuration file named .trustless-bridge-cli.yaml
in the user's home directory. You can also specify a custom configuration file path using the global --config
flag.
There is a sample .trustless-bridge-cli.yml
file in the root of the repository that you can use as a reference.
wallet_mnemonic
: This key is used to specify the mnemonic phrase for the wallet.wallet_version
: This key indicates the version of the wallet being used, which include: v1r1, v1r2, v1r3, v2r1, v2r2, v3r1, v3r2, v3, v4r1, v4r2, v5r1beta, v5r1final.wallet_workchain
: This key is used to specify the workchain for the wallet, which is necessary for deploying the wallet contract.lite_client_code
: This key is used to specify the code for the lite client, which is necessary for deploying the lite client contract.tx_checker_code
: This key is used to specify the code for the transaction checker, which is necessary for deploying the transaction checker contract.
These keys are required for executing the deploy
, run
, and get
commands. If you don't use such commands, you can leave them empty.
Make sure you have Go installed (version 1.23.1 or later).
-
Clone the Repository
git clone https://github.com/RSquad/trustless-bridge-cli.git cd trustless-bridge-cli
-
Build the Project
go build -o trustless-bridge-cli main.go
This command compiles the project into an executable named
trustless-bridge-cli
in the current directory. -
Install into Go Workspace (Optional)
To install the CLI into your
$GOPATH/bin
, run:go install
Once installed, you can call the CLI from any terminal session without specifying the path.
You can specify the network using the global --network
flag, which can be either testnet
or fastnet
. The default is testnet
.
After building or installing, you can run the utility:
trustless-bridge-cli block fetch -s <seqno> -w <workchain> -f <output-format> --network <network>
Alternatively, you can run it directly with go run
(no need to build beforehand):
go run main.go block fetch -s <seqno> -w <workchain> -f <output-format>
Use standard shell redirection to save output to a file. For example:
go run main.go block fetch -s 27450812 -f bin > block.boc
This fetches the block with sequence number 27450812 in binary format and writes it to block.boc
.
To view help for any command, use --help
. For example:
trustless-bridge-cli block --help
go run main.go deploy all -s 706883 --network testnet --config ./.trustless-bridge-cli.yaml
This command will fetch the nearest previous key block from the specified sequence number 706883
from fastnet, mark it as trusted, and deploy the LiteClient and TxChecker in the testnet with the trusted block.
Note: The command fetches data from fastnet and deploys it to testnet if the --network
flag is specified as testnet and vice versa.
go run main.go send check-tx -a EQCzBNUbnja6DRzZYwPj6HXS2IwHE4Oz9zYpun9MxXNmsHJN -t 0908bfb9eb41b3186e63ab043142a3c4d493bfbaa3013094f17a15d3575a3138 -s 706883 --network testnet --config ./.trustless-bridge-cli.yaml
This command will fetch block 706883
and transaction 0908bfb9eb41b3186e63ab043142a3c4d493bfbaa3013094f17a15d3575a3138
from fastnet, build proof, construct the message body check_transaction#91d555f7 transaction:^Cell proof:^Cell current_block:^Cell = InternalMsgBody;
, and send it to the testnet to the address EQCzBNUbnja6DRzZYwPj6HXS2IwHE4Oz9zYpun9MxXNmsHJN
.
Note: The command fetches data from fastnet and sends it to testnet if the --network
flag is specified as testnet and vice versa.
go run main.go send check-block -s 706883 -a EQDKMJuFSh4fWyciNGzDZU243rmBG80-uMMkFCMWWk98lA1X --network testnet --config .env.yaml
This command sends a check_block
message for block 706883
from fastnet to the address EQDKMJuFSh4fWyciNGzDZU243rmBG80-uMMkFCMWWk98lA1X
on the testnet.
Note: The command fetches data from fastnet and sends it to testnet if the --network
flag is specified as testnet and vice versa.
go run main.go send new-key-block -s 680939 -a EQDKMJuFSh4fWyciNGzDZU243rmBG80-uMMkFCMWWk98lA1X --network testnet --config .env.yaml
This command sends a new_key_block
message for block 680939
from fastnet to the address EQDKMJuFSh4fWyciNGzDZU243rmBG80-uMMkFCMWWk98lA1X
on the testnet.
Note: The command fetches data from fastnet and sends it to testnet if the --network
flag is specified as testnet and vice versa.
LiteClient: Ef_cmIsszQinqjDnK4LIib3vSBE8Zhf-ytgRJDGispoD-Et5
TxChecker: Ef8zZWfeh22ib982EIgo_FZM0n2Iym1WHFBRBA_H7BEfsoMK
LiteClient: EQBGWoImJJ8Uw4Lz0b2yXjpOf31awQfXHJthrYB4zppnL3c1
TxChecker: EQCEILr1N8ey9Ar-9OtnCq8A4v217lsE0pJuEZgrZOStAVVa
Transaction history with demonstration of successful and unsuccessful checks of blocks and transactions: testcases.md