Skip to content

Commit

Permalink
feat: add more docs on the tfchain bridge (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanVerstraete authored Jul 31, 2023
1 parent 54116f4 commit 873cb7e
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 71 deletions.
2 changes: 1 addition & 1 deletion bridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ Can be interacted with on: https://dashboard.dev.grid.tf

## Development

See [development](./docs/development.md) to learn more.
See [development](./docs/readme.md) to learn more.
Binary file added bridge/docs/assets/add_validator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Transfering TFT between Stellar and TF Chain testnet
# Bridging TFT between Stellar and TF Chain

## Usage

Expand All @@ -7,10 +7,11 @@ This document will explain how you can transfer TFT from TF Chain to Stellar and
## Prerequisites

- Threefold Connect application or any other Stellar wallet
- A running bridge and bridge wallet address

## Stellar to TF Chain

Transfer the TFT from your Stellar wallet to the following bridge address: `GA2CWNBUHX7NZ3B5GR4I23FMU7VY5RPA77IUJTIXTTTGKYSKDSV6LUA4`. A depositfee of 1 TFT will be taken, so make sure you send a larger amount as 1 TFT.
Transfer the TFT from your Stellar wallet to bridge wallet address that you configured. A depositfee of 1 TFT will be taken, so make sure you send a larger amount as 1 TFT.

### Transfer to TF Chain

Expand All @@ -27,7 +28,7 @@ To deposit to a TF Grid object, this object **must** exists. If the object is no

## TF Chain to Stellar

Browse to https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ftfchain.test.threefold.io#/extrinsics , select tftBridgeModule and extrinsic: `swap_to_stellar`. Provide your stellar target address and amount and sign it with your account holding the tft balance.
Browse to https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/extrinsics , select tftBridgeModule and extrinsic: `swap_to_stellar`. Provide your stellar target address and amount and sign it with your account holding the tft balance.
Again, a withdrawfee of 1 TFT will be taken, so make sure you send a larger amount as 1 TFT.

The amount withdrawn from TF Chain will be sent to your Stellar wallet.
Expand Down
18 changes: 18 additions & 0 deletions bridge/docs/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Development

## Installing

See [installing](./install.md)

## Prerequisites:

- Install and run [tfchain](https://github.com/threefoldtech/tfchain/blob/development/docs/development/development.md)
- Install [stellar-utils-tool](https://github.com/threefoldfoundation/tft/tree/main/bsc/bridges/stellar/utils)

## Local single node development

Running a local [single-node](./single_node.md) setup

## Local mutlinode development

Running a local [multinode](./multinode.md) setup
10 changes: 5 additions & 5 deletions bridge/tfchain_bridge/building.md → bridge/docs/docker.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# Building the bridge

## local build

This is a normal go project so just execute `go build`.
# Building the bridge with docker

## Build a docker image

Expand All @@ -14,3 +10,7 @@ Note: this assumes you are in this directory (bridge/tfchain_bridge)
cd ../../
docker build -t tftchainstellarbridge:$(git describe --abbrev=0 --tags | sed 's/^v//') . -f bridge/tfchain_bridge/Dockerfile
```

## Note

We rely on ../../client/tfchain-go-client in this bridge project. So this is the reason why we need to build this bridge from the root of the repository.
2 changes: 1 addition & 1 deletion bridge/docs/multinode.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Given this command did not give an error, your account you just generated now ha

## Step 4: Deposit TFT to the bridge

If
Make sure that

- Tfchain is running
- The bridge daemons are running
Expand Down
64 changes: 64 additions & 0 deletions bridge/docs/production.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Production setup

## Prerequisites

- Stellar account that has multisig enabled with a threshold of at least 2.
- As many tfchain accounts as the number of signers on the Stellar account.
- A running tfchain instance with the bridge pallet included.

## Setup

### Stellar

Generate a new keypair for the "master" bridge account. This account will be used to vault all the tokens on the Stellar side. This account will be a multisig account so you need to set the threshold to the number of signers you want to use.

There are 2 ways to do this:

- Manually using the [js-sdk](https://github.com/threefoldtech/js-sdk)
- Using any other official Stellar wallet that supports multisig (stellar laboratory, stellarport, stellarterm, ...)

These steps will not be documented here since they are subject to change.

### Tfchain

For every signer a tfchain account needs to be created. This can be done using the [subkey](https://docs.substrate.io/reference/command-line-tools/subkey/) tool.


```bash
subkey generate
```

Now ask the council or admin to add the public address to the list of bridge validators. Example of how to add a bridge validator:

![add_validator](./assets/add_validator.png)

### Bridge daemons

Once the Stellar and tfchain side have been set up, the bridge daemons can be started.

#### From Source

To install a bridge daemon:

```bash
cd tfchain_bridge
go build .
```

Start a bridge daemon:

```
./tfchain_bridge --secret STELLAR_SECRET --tfchainurl ws://localhost:9944 --tfchainseed "MNEMONIC_WORDS" --bridgewallet "STELLAR_BRIDGE_MASTER_ADDRESS" --persistency ./node.json --network production
```

#### Docker

To run a bridge daemon using docker:

To build the docker image see [docker](./docs/docker.md)


```bash
docker run -d --name tftchainstellarbridge -v /path/to/node.json:/node.json tfchain-bridge --secret STELLAR_SECRET --tfchainurl ws://localhost:9944 --tfchainseed "MNEMONIC_WORDS" --bridgewallet "STELLAR_BRIDGE_MASTER_ADDRESS" --persistency ./node.json --network production
```

17 changes: 8 additions & 9 deletions bridge/docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
In this document we will explain how the bridge works and how you can setup a local instance to develop against.
The local instance will consist of a connection between a tfchain that runs in development mode and Stellar Testnet.

## Installing
See [architecture](./architecture.md) for more information on how the bridge works.

See [installing](./intall.md)
## Development setup

## Prerequisites:
Refer to [development](./development.md) for more information on how to setup a development instance.

- Install and run [tfchain](https://github.com/threefoldtech/tfchain/blob/development/docs/development/development.md)
- Install [stellar-utils-tool](https://github.com/threefoldfoundation/tft/tree/main/bsc/bridges/stellar/utils)
## Production setup

## Local single node development
Refer to [production](./production.md) for more information on how to setup a production instance.

Running a local [single-node](./single_node.md) setup
## Bridging

## Local mutlinode development
When you have setup the bridge in either development or production mode you can start bridging.

Running a local [multinode](./multinode.md) setup
See [bridging](./bridging.md) for more information on how to bridge.
2 changes: 1 addition & 1 deletion bridge/docs/single_node.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Given this command did not give an error, your account you just generated now ha

## Step 4: Deposit TFT to the bridge

If
Make sure that

- Tfchain is running
- The bridge daemons are running
Expand Down
2 changes: 1 addition & 1 deletion bridge/tfchain_bridge/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

TFT Bridge between Tfchain and stellar.

Build instructions are explained in the [building document](building.md).
See [docs](./docs/readme.md) for more information.
1 change: 0 additions & 1 deletion bridge/tfchain_bridge/signer3.json

This file was deleted.

49 changes: 0 additions & 49 deletions bridge/tfchain_bridge/transfers_devnet.md

This file was deleted.

0 comments on commit 873cb7e

Please sign in to comment.