{"id":13630467,"url":"https://github.com/anyswap/CrossChain-Bridge","last_synced_at":"2025-04-17T13:32:28.276Z","repository":{"id":38070886,"uuid":"274037249","full_name":"anyswap/CrossChain-Bridge","owner":"anyswap","description":"Cross-Chain bridge based on Anyswap MPC network. ","archived":false,"fork":false,"pushed_at":"2023-04-10T07:47:15.000Z","size":84240,"stargazers_count":281,"open_issues_count":17,"forks_count":162,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-11-08T21:38:57.967Z","etag":null,"topics":["cross-chain-bridge","mpc","tss"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anyswap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-06-22T04:10:51.000Z","updated_at":"2024-11-05T20:24:49.000Z","dependencies_parsed_at":"2024-01-14T06:49:57.555Z","dependency_job_id":"142bd77e-3d5d-41ef-a8df-94281e7443e5","html_url":"https://github.com/anyswap/CrossChain-Bridge","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anyswap%2FCrossChain-Bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anyswap%2FCrossChain-Bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anyswap%2FCrossChain-Bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anyswap%2FCrossChain-Bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anyswap","download_url":"https://codeload.github.com/anyswap/CrossChain-Bridge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249344853,"owners_count":21254750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-chain-bridge","mpc","tss"],"created_at":"2024-08-01T22:01:44.101Z","updated_at":"2025-04-17T13:32:27.797Z","avatar_url":"https://github.com/anyswap.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# crossChain-Bridge\nCross-Chain bridge based on Anyswap MPC network.\n\n# Install the Docker version\n## 1. Install Docker. This depends on your platform, on Ubuntu this works:\n```\nsudo apt update\nsudo apt install docker.io\n```\n## 2. Download the Docker image and create and run the container:\n### swap\n```\ndocker run -itd --name swap --network host --restart always -v /var/lib/docker/swap:/swap anywap/swap\n```\n### client\n```\ndocker exec -d swap swaporacle ...\n```\ntools: `swapserver swaporacle swapscan swapadmin swaptools` (/usr/local/bin)  \nconf: `config-example.toml config-tokenpair-example.toml` (/usr/local/bin)  \n\n# Install the Source version\n## Building\n\n```shell\ngit clone https://github.com/anyswap/CrossChain-Bridge.git\ncd crossChain-Bridge\nmake all\n```\n\nafter building, the following files will be generated in `./build/bin` directory:\n\n```text\nswapserver\t# server provide api service, and trigger swap processing\nswaporacle      # oracle take part in mpc signing (can disagree illegal transaction)\nconfig-example.toml\nconfig-tokenpair-example.toml\n```\n\n## Modify config file\n\ncopy the example config file `config-example.toml` in `./build/bin` directory, and modify it accordingly.\n\nsee more, please refer [config file example](https://github.com/anyswap/CrossChain-Bridge/blob/master/params/config-example.toml)\n\n#### Identifier\n\nIdentifier should be a short string to identify the bridge (eg. `BTC2ETH`, `BTC2FSN`)\n\n#### MongoDB\n\nMongoDB is used by the server to store swap status and history, you should config according to your modgodb database setting.\n(the swap oracle don't need it)\n\n#### APIServer\n\nAPIServer is used by the server to provide API service to register swap and to provide history retrieving.\n(the swap oracle don't need it)\n\n#### Oracle\n\nOracle is needed by the swap oracle to post swap register RPC requests to swap server\n(the swap server don't need `Oracle`).\n\n#### BtcExtra\n\nBtcExtra is used to customize fees when build transaction on Bitcoin blockchain\n\n#### SrcChain\n\nSrcChain is used to config the chain of source endpoint of the cross chain bridge.\n\n#### SrcGateway\n\nSrcGateway is used to do RPC request to verify transactions on source blockchain, and to broadcast signed transaction.\n\n#### DestChain\n\nDestChain is used to config the chain of dest endpoint of the cross chain bridge.\n\n#### DestGateway\n\nDestGateway is used to do RPC request to verify transactions on dest blockchain, and to broadcast signed transaction.\n\n#### Dcrm\n\nDcrm is used to config DCRM node info and group info.\n\n`Initiators` is used to specify the server dcrm user (initiators of dcrm sign)\n\n`Dcrm.DefaultNode` is used to specify default dcrm node to connect.\n\n`Dcrm.OtherNodes` is an array used by server to specify other initiators of dcrm node.\n\nfor the swap server, `SignGroups` is needed for dcrm signing.\n\nNotice:\nIf in test enviroment you may run more than one program of swap servers on one machine,\nPlease specify `different log file name` to clarify the outputs.\nAnd please specify `different config files` for each server,\nand assgin `KeystoreFile`, `PasswordFile` and `RPCAddress` etc. separatly.\n\n\n## Modify token pair config files\n\ncopy the example config file `config-tokenpair-example.toml` in `./build/bin` directory, and modify it accordingly.\n\nsee more, please refer [token pair config file example](https://github.com/anyswap/CrossChain-Bridge/blob/master/params/config-tokenpair-example.toml)\n\n#### PairID\n\npair ID of this token pair, must be unique.\n\n#### SrcToken\n\nSrcToken is used to config the token of source endpoint of the cross chain bridge.\n\n#### DestToken\n\nDestToken is used to config the token of dest endpoint of the cross chain bridge.\n\n\n## Run swap server\n\n```shell\nsetsid ./build/bin/swapserver --verbosity 6 --config build/bin/config.toml --pairsdir build/bin/tokenpairs --log build/bin/logs/server.log\n```\n\n## Run swap oracle\n\n```shell\nsetsid ./build/bin/swaporacle --verbosity 6 --config build/bin/config.toml --pairsdir build/bin/tokenpairs --log build/bin/logs/oracle.log\n```\n\n## Others\n\n`swapserver` and `swaporacle` has the following subcommands:\n\n```text\nhelp       - to see hep info.\nversion - to show the version.\nlicense - to show the license\n```\n\n## Preparations\n\nRunning  `swapserver` and `swaporacle` to provide cross chain bridge service, we must prepare the following things firstly and config them rightly. Otherwise the program will not run or run rightly. To ensure this, we have add many checkings to the config items.\n\nFor the config file, please refer [config file example](https://github.com/anyswap/CrossChain-Bridge/blob/master/params/config-example.toml)\n\n1. create Mongodb database (shared by all swap servers of the bridge provider)\n\n    config `[MongoDB]` section accordingly (eg. `DbURL`,`DbName`,`UserName`,`Password`)\n\n    For security reason, we suggest:\n    1. change the mongodb `port` ( defaults to `27017`)\n    2. enable `auth`\n    3. create user with passord to access the database\n\n2. create MPC group\n\n    For example, we take creating `2/3 theshold` jonitly managed MPC group as an example.\n\n    we have 3 users in the MPC group, each user is running a `gdcrm` node to perform MPC functions.\n\n    1. `user1` -  build raw tx and trigger MPC signing\n    2. `user2`, `user3` - verify tx and accept the MPC signing with `AGREE/DISAGREE` result\n\n    After created MPC group,\n\n    We can get the corresponding `MPC addresses` on supported blockchains. Then we should config `DcrmAddress` in `[SrcToken]` and `[DestToken]` section according to the blockchain of them.\n\n    We should config the `[Dcrm]` section accordingly（ eg. `GroupID`, `TotalOracles`，`Mode`, `DefaultNode`, etc.）\n\n    And we should config the following `[Dcrm]` section items sparately for each user in the MPC group:\n\n    1. `KeystoreFile`\n    2. `PasswordFile`\n    3. `RPCAddress`\n\n    For example,\n\n    we are configing `user1` now, we should config `KeystoreFile` and `PasswordFile` use `user1`'s keystore and password file (we will get `user1`'s private key to sign a MPC requesting).\n\n    And we should config `RPCAddress` to the RPC address of the running `gdcrm` node of `user1` (we will do RPC calls to this address to complete MPC signing or accepting, etc.)\n\n3. create MPC sub-groups for signing\n\n    In the above step we have created a `2/3 threshold` MPC group.\n\n    In signing we only need 2 members to agree.\n\n    So we prepared the sub-groups (`2/2`) for signing. (eg. user1 + user2, user1 + user3)\n    please see more detail about MPC [here](https://docs.multichain.org/how-it-works/)\n\n    After created, we should config `SignGroups` in `[Dcrm]` accordingly.\n\n4. create mapping asset (eg. mBTC) contract **`with MPC account`**\n\n    mBTC is an smart contract inherit from `ERC20` and add two methods: `Swapin` and `Swapout`.\n\n    please see more here about [mBTC](https://github.com/anyswap/mBTC)\n\n    After created mBTC, we should config `ContractAddress` in `[DestToken]` section.\n\n5. config `[APIServer]` section\n\n    The swap server provides RPC service to query swap status and swap history. etc.\n\n    Please see more here about [crossChain-Bridge-API](https://github.com/anyswap/CrossChain-Bridge/wiki/crossChain-Bridge-API)\n\n    We should config `Port` (defaults to `11556`), and `AllowedOrigins` (CORS defaults to empty array. `[\"*\"]` for allow any)\n\n6. config `[SrcChain]`,`[SrcGateway]`\n\n    We should config `APIAddress` in `[SrcGateway]` section,\n    to post RPC request to the running full node to get transaction, broadcat transaction etc.\n\n    Config `[SrcChain]`, ref. to the following example:\n\n    ```toml\n    BlockChain = \"Bitcoin\" # required\n    NetID = \"TestNet3\"  # required\n    Confirmations = 0 # suggest \u003e= 6 for Mainnet # required\n    InitialHeight = 0\n    EnableScan = false\n    ```\n\n7. config `[DestChain]`, `[DestGateway]`\n\n    We should config `APIAddress` in `[DestGateway]` section,\n    to post RPC request to the running full node to get transaction, broadcat transaction etc.\n\n    Config `[DestChain]` like `[SrcChain]`.\n\n8. config `Identifier` to identify your crosschain bridge\n\n    This should be a short string to identify the bridge (eg. `BTC2ETH`, `BTC2FSN`)\n\n    Different MPC group can have same Identifier.\n\n    It only matter if you want use a MPC group to provide multiple crosschain bridge service, and config each bridge with a different identifier (`Notice: This way is not suggested`)\n\n9. config `[BtcExtra]`\n\n    When build and sign transaction on Bitcoin blockchain, we can customize the following items:\n\n    ```toml\n    MinRelayFee   = 400\n    RelayFeePerKb = 2000\n    UtxoAggregateMinCount = 20\n    UtxoAggregateMinValue = 1000000\n    ```\n\n    If not configed, the default vlaue will be used (in fact, the above values are the defaults)\n\n10. config `[SrcToken]`\n\n    Config `[SrcToken]`, ref. to the following example:\n\n    ```toml\n    ID = \"\"\n    Name = \"Bitcoin Coin\"\n    Symbol = \"BTC\"\n    Decimals = 8  # required\n    Description = \"Bitcoin Coin\"\n    ContractAddress = \"\"\n    DepositAddress = \"mq6XaNvFWiSJtfGYiGakkRdXNrqH6V4Jpu\" # required\n    DcrmAddress = \"mfwPnCuht2b4Lvb5XTds4Rvzy3jZ2ZWrBL\" # required\n    DcrmPubkey = \"045c8648793e4867af465691685000ae841dccab0b011283139d2eae454b569d5789f01632e13a75a5aad8480140e895dd671cae3639f935750bea7ae4b5a25122\"\n    MaximumSwap = 1000.0 # required\n    MinimumSwap = 0.00001 # required\n    SwapFeeRate = 0.001 # required\n    MaximumSwapFee = 0.01\n    MinimumSwapFee = 0.00001\n    PlusGasPricePercentage = 15\n    BigValueThreshold = 5.0\n    DisableSwap = false\n    ```\n\n    For ERC20 token, we should config `ID = \"ERC20\"` and `ContractAddress` to the token's contract address.\n\n11. config `[DestToken]`\n\n    Config `[DestToken]` like `[SrcToken]`.\n\n    Don't forget to config  `ContractAddress` in `[DestToken]` section  (see step 4)\n\n12. config `PairID` to identify token pair\n\n```text\nrepeat step 10, 11, 12 to prepare multiple token pairs config,\nput them in a directory (will be referenced by --pairsdir command line option)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanyswap%2FCrossChain-Bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanyswap%2FCrossChain-Bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanyswap%2FCrossChain-Bridge/lists"}