Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: initialize docs for btc support #158

Merged
merged 11 commits into from
Jul 25, 2024
11 changes: 10 additions & 1 deletion dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -480,4 +480,13 @@ MAINNET
sygma-props
SygmaProtocolReactWidget
setState
Paseo
UTXO-based
stateful
UTXO
BTC
tBTC
LGPL-3.0
sygma-docs
sygma-shared-configuration
IPFS
Paseo
21 changes: 17 additions & 4 deletions docs/01-introduction/01-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,33 @@ title: Introduction
description: The following describes an introduction of Sygma.
---

# Welcome to Sygma Docs
# Home

![](https://blog.buildwithsygma.com/content/images/2023/06/full-logo-3.png)

## Welcome To The Sygma Docs

> _Sygma, like the Greek letter sigma (Σ), alludes to summation, the adding up of many things._

Sygma is a fully open source ([Lesser General Public License version 3.0 (LGPL-3.0)](https://www.gnu.org/licenses/lgpl-3.0.html)) multi-purpose interoperability layer that supports developers in building cross-chain dApps. A key part in this is removing complexity from the equation. Sygma empowers builders to create streamlined experiences by abstracting the complexities of bridging away and enabling smooth, web2-like user experiences.
Sygma is an open-source interoperability layer licensed under [LGPL-3.0](https://www.gnu.org/licenses/lgpl-3.0.html), designed to support the development of cross-chain decentralized applications (dApps). It abstracts the underlying complexities of blockchain bridging, enabling developers to create dApps that facilitate cross-chain token transfers and generic message passing. Sygma integrates with multiple blockchain environments, providing tools for efficient cross-chain communication. This documentation covers technical and non-technical aspects of the protocol, aiming to equip both novice and experienced developers with the knowledge to leverage Sygma effectively in their projects.

## What's Next

- Get started with our [Quick Start Guide](../03-sygma-sdk/01-index.md)
- Get started with the Sygma SDK [Quick Start Guide](../03-sygma-sdk/01-index.md)
- Run your first [cross-chain token transfer](../03-sygma-sdk/04-Examples/01-Basic-ERC-20-Token-Transfers/01-EVM-EVM-example.md)
- Pass your first [generic message cross-chain](../03-sygma-sdk/04-Examples/02-GMP-Examples/01-GMP-Example-With-A-Simple-Storage-Contract.md)
- See the [environments](../08-resources/01-environments/01-index.md) Sygma is deployed in
- Look under the hood at the [architecture](../02-sygma-protocol/01-index.md)
- Find out how Sygma's [Tailored Security](../02-sygma-protocol/02-Tailored-Security/01-index.md) works
- Integrate the [Sygma Widget](https://docs.buildwithsygma.com/sygma-widget/playground/) into your dApp
- Read more on the [Sygma Vision](02-origins.md)

For the complete source code, please check out [Sygma's GitHub Repositories](../08-resources/04-github-repositories.md).
For the complete source code, please check out [Sygma's GitHub Repositories](../08-resources/04-github-repositories.md).

## About These Docs

This documentation is open source and can be found at [sygma-docs](https://github.com/sygma-protocol/docs). For more on contributing, please see [Contribute](../10-contribute.md).

## Need Assistance?

First, make sure to check out the [FAQs](../09-faq.md). If you have questions about the protocol, the code, the docs, or have a business inquiry, please reach out to us on [Discord](https://discord.gg/Qdf6GyNB5J) or by filling out [this form](https://share.hsforms.com/1K4-T_yaKSp6F06FGk4wsSgnmy2x).
2 changes: 2 additions & 0 deletions docs/02-sygma-protocol/04-Supported-Ecosystems/01-evm.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ description: The following details EVM support on Sygma.
The following section details Sygma's compatibility with EVM chains via its ecosystem of smart contracts.
:::

# Introduction To EVM Support

Sygma uses Solidity smart contracts to enable transfers to and from Ethereum Virtual machine (EVM) compatible chains. These contracts consist of a core bridge contract (`Bridge.sol`), and a set of handler contracts (e.g. `ERC20Handler.sol`, `ERC721Handler.sol`, `PermissionlessGenericHandler.sol`, `FeeHandlerRouter.sol`, `BasicFeeHandler.sol`). [Different verification systems](../02-Tailored-Security/01-index.md) also require separate sets of smart contracts. These onchain components establish a relationship with the offchain actors via generation and detection of onchain contract events.

## Sygma's Smart Contracts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ description: The following details Substrate support on Sygma.
The following section details Sygma's compatibility with Polkadot and Kusama parachains via its Substrate pallet support.
:::

# Introduction To Substrate Support

A unique feature of the Sygma protocol is its ability to provide interoperability between EVM-based and Substrate-based blockchains. This includes those [parachains](https://wiki.polkadot.network/docs/learn-parachains) deployed under Polkadot and Kusama's [shared security model](https://wiki.polkadot.network/docs/learn-architecture).

Similar to how Sygma enables EVM support by invoking various smart contracts, Sygma provides Substrate support via interactions with [custom Sygma pallets](https://github.com/sygmaprotocol/sygma-substrate-pallets).
Expand Down
54 changes: 53 additions & 1 deletion docs/02-sygma-protocol/04-Supported-Ecosystems/03-btc.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,56 @@ id: protocol-btc
title: Bitcoin Support
description: The following details Bitcoin support on Sygma.
draft: true
---
---

:::info
The following section details Sygma's compatibility with Bitcoin and its constituent layer-2's.
:::

# Introduction To Bitcoin Support

The Sygma protocol extends its support to Bitcoin and its associated layer-2 networks. A notable characteristic of chains built on EVM and Substrate is their capability to generate event logs from transactions and contract interactions. These event logs are particularly useful for tracking onchain interactions *externally*, and therefore are essential to Sygma's relayer network. The relayer network listens for these events, interprets the logs, parses the messages within them, verifies the authenticity of these computations, and posts them to the destination chains. However, Bitcoin and other UTXO-based chains generally do not produce event logs, as they do not have a concept of "state" in the same way stateful chains do.

To get around this limitation, Sygma configures its MPC relayers to monitor specific deposit addresses on Bitcoin. When a transaction, or UTXO in Bitcoin-terms, is made to these deposit addresses, the protocol treats it similarly to an event on EVM. During the transaction where this deposit occurs, relayers look for an additional UTXO called `OP_RETURN`, which encodes 80-bytes of arbitrary information (i.e. metadata) within the transaction. This is how the relayer network obtains details of the cross-chain transaction including EVM addresses and other metadata.

## How Does Sygma Handle Bitcoin Cross-Chain?

Sygma facilitates the transfer of Bitcoin to Ethereum by setting up specific Bitcoin deposit addresses and employing a series of event listeners and handlers to monitor, process, and relay transactions. This process involves several steps to ensure secure and accurate cross-chain communication. The following sections detail the technical components and workflow involved in this process, illustrating how Bitcoin transactions are detected, processed, and converted into equivalent assets on the Ethereum blockchain.

1. Configuration:
- Deposit addresses are specified in [`config.go`](https://github.com/sygmaprotocol/sygma-relayer/blob/main/chains/btc/config/config.go) under the `Resources` field.

2. Listening and Detection:
- `BtcListener` in [`listener.go`](https://github.com/sygmaprotocol/sygma-relayer/blob/main/chains/btc/listener/listener.go) scans Bitcoin blocks for transactions to these addresses.
- `DecodeDepositEvent` in [`util.go`](https://github.com/sygmaprotocol/sygma-relayer/blob/main/chains/btc/listener/util.go) processes transactions and extracts metadata from `OP_RETURN`.

3. Handling Deposits:
- `BtcDepositHandler` in [`deposit-handler.go`](https://github.com/sygmaprotocol/sygma-relayer/blob/main/chains/btc/listener/deposit-handler.go) processes detected deposits and creates cross-chain messages.
- The message includes the recipient's Ethereum address and other details.

4. Event Handling:
- `FungibleTransferEventHandler` in [`event-handlers.go`](https://github.com/sygmaprotocol/sygma-relayer/blob/main/chains/btc/listener/event-handlers.go) fetches events and processes deposits, sending messages to Ethereum.

5. Message Handling:
- `BtcMessageHandler` in [`message-handler.go`](https://github.com/sygmaprotocol/sygma-relayer/blob/main/chains/btc/executor/message-handler.go) processes cross-chain messages and converts them into proposals.

6. Execution:
- `Executor` in [`executor.go`](https://github.com/sygmaprotocol/sygma-relayer/blob/main/chains/btc/executor/executor.go) signs and sends transactions.
- Constructs and sends the raw transaction to the Bitcoin network.
- Upon confirmation, the equivalent amount of wrapped BTC is minted on Ethereum.

## An Example

For an example of a cross-chain transaction on Bitcoin using the Sygma protocol, see [this transaction hash](https://blockstream.info/testnet/tx/7341772580155039004345fe17c3619f777eb5b144cde9baf040c3ac422bb74e).

**Anatomy**:
- Output Index 0: `OP_RETURN`
- Desc: Includes `OP_RETURN` data containing the metadata (`0x703265c472F169b20E8E03c842B9B374Cb842Cb8_2`). The metadata indicates the address the funds should be bridged to as well as the domain ID (`2`), which represents Ethereum Sepolia.
- Output Index 1: UTXO #1
- Desc: Contains 0.01000000 tBTC, which is the fixed fee amount for bridging with the Sygma protocol.
- Output Address: [tb1p0r2w3ugreaggd7nakw2wd04up6rl8k0cce8eetxwmhnrelgqx87s4zdkd7](https://blockstream.info/testnet/address/tb1p0r2w3ugreaggd7nakw2wd04up6rl8k0cce8eetxwmhnrelgqx87s4zdkd7)
- Output Index 2: UTXO #2
- Desc: Contains 2.48957356 tBTC, representing the amount of BTC being bridged to the EVM.
- Output Address: [tb1p72xwajwdxdfhmu5dp39sh8jdc6msnez0a7rq4gk5jeep0kvccnsqkgcj7e](https://blockstream.info/testnet/address/tb1p72xwajwdxdfhmu5dp39sh8jdc6msnez0a7rq4gk5jeep0kvccnsqkgcj7e)

![](../../../static/assets/op_return_example.png)
20 changes: 19 additions & 1 deletion docs/03-sygma-sdk/01-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ description: The following section introduces the Sygma SDK.
sidebar_position: 1
---

**Sygma SDK** is an open source library (under [GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html)) for developers to work within the Sygma ecosystem. The SDK consist of methods that enable bridging capabilities between EVM and Substrate-based networks.
<p align="center">
<a href="https://github.com/sygmaprotocol/sygma-sdk/actions/workflows/ci.yaml">
<img src="https://github.com/sygmaprotocol/sygma-sdk/actions/workflows/ci.yaml/badge.svg" alt="Build Status" />
</a>
<a href="https://www.npmjs.com/package/@buildwithsygma/sygma-sdk-core">
<img alt="npm" src="https://img.shields.io/npm/v/@buildwithsygma/sygma-sdk-core" />
</a>
<a href="https://www.npmjs.com/package/@buildwithsygma/sygma-sdk-core">
<img alt="npm downloads" src="https://img.shields.io/npm/dm/@buildwithsygma/sygma-sdk-core" />
</a>
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/sygmaprotocol/sygma-sdk" />
<br/>
<img alt="GitHub" src="https://img.shields.io/github/license/sygmaprotocol/sygma-sdk" />
<a href="https://discord.gg/Qdf6GyNB5J">
<img alt="discord" src="https://img.shields.io/discord/999966147644493824?label=Discord&logo=discord&style=flat" />
</a>
</p>

**Sygma SDK** is an open source library (under [GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html)) for developers to work within the Sygma ecosystem. The SDK consist of methods that enable bridging capabilities between networks built on EVM, Substrate, Bitcoin, and beyond.

**NOTE:** the SDK is under active development. We encourage developers that discover any bugs or are interested in extending SDK functionality to [submit issues](https://github.com/sygmaprotocol/sygma-sdk/issues) to our GitHub.
4 changes: 2 additions & 2 deletions docs/04-integrating-with-sygma/04-new-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ The following section details how to request support for a new network. The Sygm

Sygma currently supports EVM and Substrate-based networks natively, with support for Bitcoin and Cosmos-based ecosystems coming soon. The currently supported networks can be found in the links below. The linked pages also contain information on supported resource types, contract addresses, and available fee schemas:

- [Testnet Network Support](https://docs.buildwithsygma.com/environments/testnet/#contract-addresses)
- [Mainnet Network Support](https://docs.buildwithsygma.com/environments/mainnet#contract-addresses)
- [Testnet Network Support](../08-resources/01-environments/03-testnet/index.md)
- [Mainnet Network Support](../08-resources/01-environments/04-mainnet.md)

If there is a network that is not yet supported and you would like Sygma to add support, please contact us on [Discord](https://discord.gg/Qdf6GyNB5J) or fill out [this form](https://share.hsforms.com/1K4-T_yaKSp6F06FGk4wsSgnmy2x).
20 changes: 11 additions & 9 deletions docs/08-resources/04-github-repositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ The following details a list of relevant Sygma repositories.

| Repository | Description | Status |
| ---- |-------------| ------ |
| [**sygma-core**](https://github.com/sygmaprotocol/sygma-core) | Contains core Sygma logic implemented in Go | Public repository, [audited](audits/); beta. |
| [**sygma-core**](https://github.com/sygmaprotocol/sygma-core) | Contains core Sygma logic implemented in Go | Public repository, [audited](audits/); production. |
| [**sygma-sdk**](https://github.com/sygmaprotocol/sygma-sdk) | Tools to easily integrate any JS application with protocol Sygma | Public repository; production.|
| [**sygma-solidity**](https://github.com/sygmaprotocol/sygma-solidity) | Smart contracts used by protocol Sygma | Public repository, [audited](audits/); beta. |
| [**sygma-solidity**](https://github.com/sygmaprotocol/sygma-solidity) | Smart contracts used by protocol Sygma | Public repository, [audited](audits/); production. |
| [**sygma-x-solidity**](https://github.com/sygmaprotocol/sygma-x-solidity) | Contains the zk verification contracts used by Sygma Spectre | Public repository, [audited](audits/); beta. |
| [**sygma-substrate-pallets**](https://github.com/sygmaprotocol/sygma-substrate-pallets) | This repo contains several substrate pallet implementation for Sygma protocol | Public repository, [audited](audits/); beta. |
| [**sygma-relayer**](https://github.com/sygmaprotocol/sygma-relayer) | Go-implemented relayer service | Public repository, [audited](audits/); beta. |
| [**sygma-substrate-pallets**](https://github.com/sygmaprotocol/sygma-substrate-pallets) | This repo contains several substrate pallet implementation for Sygma protocol | Public repository, [audited](audits/); production. |
| [**sygma-relayer**](https://github.com/sygmaprotocol/sygma-relayer) | Go-implemented relayer service | Public repository, [audited](audits/); production. |
| [**spectre-node**](https://github.com/sygmaprotocol/spectre-node) | Go-implemented zk relayer node | Public repository; beta. |
| [**sygma-inclusion-prover**](https://github.com/sygmaprotocol/sygma-inclusion-prover) | Sygma inclusion prover for zk verification | Public repository; beta. |
| [**sygma-widget**](https://github.com/sygmaprotocol/sygma-widget) | Customizable widget for public integration of protocol Sygma | Public repository; beta. |
| [**sygma-ui**](https://github.com/sygmaprotocol/sygma-ui) | Application TransferUI that uses sygma-sdk to interact with Sygma smart contracts and blockchains | Public repository; beta. |
| [**explorer-ui**](https://github.com/sygmaprotocol/sygma-substrate-pallets) | ExplorerUI is used to track and navigate Sygma ecosystem | Public repository; beta. |
| [**sygma-explorer-indexer**](https://github.com/sygmaprotocol/sygma-explorer-indexer) | Indexer used by the Sygma Explorer | Public repository; beta. |
| [**fee-oracle**](https://github.com/sygmaprotocol/sygma-fee-oracle) | Go-implemented service that provides endpoints to Sygma UI for all necessary data related to bridging fees. | Private repository, audit underway (publicly available upon completion); beta. |
| [**sygma-widget**](https://github.com/sygmaprotocol/sygma-widget) | Customizable widget for public integration of protocol Sygma | Public repository; production. |
| [**sygma-ui**](https://github.com/sygmaprotocol/sygma-ui) | Application TransferUI that uses sygma-sdk to interact with Sygma smart contracts and blockchains | Public repository; production. |
| [**explorer-ui**](https://github.com/sygmaprotocol/sygma-substrate-pallets) | ExplorerUI is used to track and navigate Sygma ecosystem | Public repository; production. |
| [**sygma-explorer-indexer**](https://github.com/sygmaprotocol/sygma-explorer-indexer) | Indexer used by the Sygma Explorer | Public repository; production. |
| [**sygma-shared-configuration**](https://github.com/sygmaprotocol/sygma-shared-configuration) | This repository uploads shared domains configuration to IPFS (CS Storage) for each Sygma environment. | Public repository; production. |

<!-- | [**fee-oracle**](https://github.com/sygmaprotocol/sygma-fee-oracle) | Go-implemented service that provides endpoints to Sygma UI for all necessary data related to bridging fees. | Private repository, audit underway (publicly available upon completion); beta. | -->

Binary file added static/assets/op_return_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading