{"id":27429405,"url":"https://github.com/byteball/counterstake-bridge","last_synced_at":"2026-03-03T08:43:24.170Z","repository":{"id":41408344,"uuid":"381327063","full_name":"byteball/counterstake-bridge","owner":"byteball","description":"Assistant/watchdog for Counterstake Bridge https://counterstake.org","archived":false,"fork":false,"pushed_at":"2025-12-26T09:59:35.000Z","size":560,"stargazers_count":13,"open_issues_count":0,"forks_count":16,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-27T21:47:26.384Z","etag":null,"topics":["autonomous-agents","cross-chain","cross-chain-bridge","cryptocurrency","dapp","decentralized-finance","defi","ethereum","interchain","interoperability","obyte","smart-contracts"],"latest_commit_sha":null,"homepage":"https://counterstake.org","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/byteball.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":"audits/Counterstake-audit-by-Dedaub.pdf","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-06-29T10:33:51.000Z","updated_at":"2025-12-26T09:59:38.000Z","dependencies_parsed_at":"2023-02-15T12:35:28.337Z","dependency_job_id":"edb78733-4bfd-4cc4-870f-62cdebde72c0","html_url":"https://github.com/byteball/counterstake-bridge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/byteball/counterstake-bridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteball%2Fcounterstake-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteball%2Fcounterstake-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteball%2Fcounterstake-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteball%2Fcounterstake-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/byteball","download_url":"https://codeload.github.com/byteball/counterstake-bridge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteball%2Fcounterstake-bridge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30038535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T06:58:30.252Z","status":"ssl_error","status_checked_at":"2026-03-03T06:58:15.329Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["autonomous-agents","cross-chain","cross-chain-bridge","cryptocurrency","dapp","decentralized-finance","defi","ethereum","interchain","interoperability","obyte","smart-contracts"],"created_at":"2025-04-14T14:17:34.928Z","updated_at":"2026-03-03T08:43:24.137Z","avatar_url":"https://github.com/byteball.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Counterstake assistant and watchdog\n\nRun this bot to assist users with cross-chain transfers facilitated by [counterstake protocol](https://counterstake.org) and earn assistant rewards (initially, 1%) on each transfer.\n\nThe bot also serves as watchdog. It monitors the ongoing transfers and if it sees a fraudulent claim or challenge, it sends a counterstake looking to win the stake posted by the fraudulent claim or challenge. The potential ROI is 66.7%. See [how counterstake works](https://counterstake.org/how-it-works).\n\nCurrently, the bot supports transfers between Obyte, Ethereum, and BSC.\n\nThe are no guarantees of the correct operation of the software. There might be bugs which can lead to losing money. Use at your own risk.\n\n## Requirements\nnodejs 12+\n\n## Install\nGet the repo:\n```bash\ngit clone https://github.com/byteball/counterstake-bridge\ncd counterstake-bridge\nyarn\n```\n\nIt should automatically compile Ethereum contracts during install, but in case any error occures, you can compile them manually:\n```bash\ncd evm\nyarn global add truffle\ntruffle compile\n```\n\n## Run\n```bash\nnode run.js bridge 2\u003eerrlog\n```\n\n## Funding\nWhen the bot starts, it prints its addresses, like this:\n```\n====== my single address: TNM2YRTJOANVGXMCFOH2FBVC3KYHZ4O6\n```\nThis is your Obyte address. Fund it with GBYTE and any Obyte tokens that users are likely to expatriate to other chains. Larger balances will enable you to serve larger transfers and win competition against other assistant bots.\n```\n====== my Ethereum address:  0xEA6D65BAE2E0dDF1A3723B139cb989FAbCD63318\n```\nThis is your Ethereum address. Fund it with ETH and any ERC20 tokens that users are likely to expatriate to other chains. Larger balances will enable you to serve larger transfers and win competition against other assistant bots.\n```\n====== my BSC address:  0xEA6D65BAE2E0dDF1A3723B139cb989FAbCD63318\n```\nThis is your BSC address. Fund it with BNB and any BEP20 tokens that users are likely to expatriate to other chains. Larger balances will enable you to serve larger transfers and win competition against other assistant bots.\n\nLarger balances also allow you to serve more transfers in parallel before your bot's capacity is exhausted.\n\nNext, to be able to assist users with expatriations, you need to fund the bot with imported tokens on foreign chains. To do that, transfer some tokens to your bot via [counterstake.org](https://counterstake.org) by specifying your bot's address as the recipient. E.g. transfer GBYTE from Obyte to your bot's Ethereum address, transfer ETH and USDC from Ethereum to your bot's Obyte address, and so on. Note that the challenging period is 3 days by default, therefore the imported tokens will be available to your bot only after 3 days. If you want to top up the bot's balances in the future, plan that in advance as the transfer will take 3 days again.\n\nYou can track the bot's balances through the explorers on the respective chains.\n\n## Email notifications\nIf the bot complains about `admin_email` and `from_email`, specify them in ~/.config/counterstake-bridge/conf.json. In case of any issues, you'll get notifications to `admin_email`.\n\nAdd `check_daemon.js` to your crontab. See `crontab.txt` for the line to be added to your crontab. If your crontab is empty, just run\n```bash\ncrontab crontab.txt\n```\nYou'll receive notifications to your `admin_email` if the bot crashes.\n\nCheck that the notifications work before leaving the bot to run in production. For this, kill the bot and run\n```bash\nnode check_daemon.js\n```\nYou should receive an email that the bot is down.\n\nIf `sendmail` is not setup and configured on your system (usually, it isn't), add the following settings to your conf.json to send emails through an external SMTP server instead:\n```json\n\t\"smtpTransport\": \"relay\",\n\t\"smtpRelay\": \"\u003cSMTP server such as smtp.gmail.com\u003e\",\n\t\"smtpUser\": \"\u003cyour account at this mail server\u003e\",\n\t\"smtpPassword\": \"\u003cyour password for SMTP authentication\u003e\"\n```\n\n## Configuration\nCheck `conf.js` for the available options. You can override them in your conf.json. The most important ones are:\n* `infura_project_id`: your infura project ID. Sign up at infura to get it.\n* `alchemy_keys`: your alchemy keys. Sign up at alchemy to get them. The format is like\n```json\n\t\"alchemy_keys\": {\n\t\t\"polygon\": {\n\t\t\t\"mainnet\": \"\u003cyour mainnet key\u003e\",\n\t\t\t\"testnet\": \"\u003cyour testnet key\u003e\"\n\t\t}\n\t},\n```\n* `min_reward_ratio`: minimum net reward (net of gas fees) that your bot expects to earn for assisting a transfer. The bot will ignore the transfers that pay a lower reward. Default 0.005 (0.5%).\n* `max_exposure`: max share of the bot's balance in a specific token that can be sent in a counterstake against a fraudulent claim a challenge. This limits the risk you are taking. Default 0.5 (50%).\n* `evm_min_transfer_age`: minimum age (in seconds) of the transfer on an EVM-based source chain before it is deemed irreversible and safe to claim on the destination chain. The default is 300 seconds (5 minutes). You can set a lower value to make sure your bot claims a transfer before other assistant bots but this also increases the risk that the transfer will be reverted and your bot will lose money.\n* `evm_count_blocks_for_finality`: if your bot sees a new claim for a transfer sent from an EVM-based chain but can't find the transfer, and its timestamp is earlier than that of the block `evm_count_blocks_for_finality` blocks ago, then the bot will think that the transfer doesn't exist and will counterstake against the claim. Otherwise, the bot will wait for a few more blocks and check again if the tranfer has appeared in the source chain. The default is 20 blocks. Set a lower value to make sure that your bot counterstakes earlier than other watchdogs but this also increases the risk that the transfer will still appear in the source chain and your bot will lose money.\n* `bLight`: whether to run the bot as a light Obyte node. Default `true`. Running a full node allows the bot to see new transactions slightly faster and is also more secure as the bot doesn't need to trust any external sources. However a full node takes a lot more disk space and its initial sync takes several days.\n* `socksHost` and `socksPort`: host and port for connecting to TOR proxy. By default, the bot is configured to connect to Obyte nodes through TOR. To disable TOR, set `socksHost` to `null`.\n* `control_addresses`: array of device addresses of your Obyte wallets (usually GUI wallets) that are allowed to view and withdraw balances using chatbot interface.\n* `payout_addresses`: associative array of your withdrawal addresses keyed by network.\n\n## Running as a pooled assistant\nIf the bot notices that a pooled assistant has been created for a specific bridge and the bot's address is set as the manager, the bot will start using the pool's money for claiming and counterstaking on that bridge when sufficient funds are available.\n\nThere is no UI for contributing to the pools yet, so this is not a real option at the moment.\n\n## Managing the bot and withdrawing funds\nWhen the bot starts, it prints its pairing code, like this:\n```\n====== my pairing code: AzA8qzvoMEnf7vVyo4YCw7u/hIiDOb8APpTmIPttP/29@obyte.org/bb-test#0000\n```\nUse this code to pair your GUI wallet with the bot and manage it through chat interface.\n\nSet `control_addresses` in your conf.json to let the bot know who is allowed to manage it (by default, nobody is allowed). Set your `payout_addresses` addresses to enable withdrawals to your Obyte, Ethereum, and other addresses (by default, withdrawals are disabled), like this:\n```\n        \"payout_addresses\": {\n                \"Obyte\": \"EJC4A7WQGHEZEKW6RLO7F26SAR4LAQBU\",\n                \"Ethereum\": \"0xbd2C1400eA794D837669d3A83Ef8B3534579b5BF\"\n        },\n```\n\nType `help` in chat to see the available commands. In particular, you can use `balances` command to view the bot's balances in all currencies, `deposit` to add funds, `withdraw` to withdraw funds from the bot's balance to your payout addresses.\n\n## Adding new bridges\nSee `setup_bridges.js` and edit `setupAdditionalBridge()` as appropriate.\n\n## Adding new chains\nTo add a new EVM-based chain, see the source code of `ethereum.js` and `bsc.js`, add a similar class, and use it in `transfers.js`. Edit and run `emv/deploy-contracts.js` to deploy the contracts.\n\nTo add a new Obyte-based chain, see `obyte.js` and define a descendant class, then use it in `transfers.js`. Edit and run `deploy-aas.js` to deploy the autonomous agents.\n\nTo add a chain that is neither EVM-based nor Obyte-based, develop its programmable agents (such as autonomous agents on Obyte, smart contracts on Ethereum, chaincode on Hyperledger Fabric) that implement the Counterstake protocol, write a class similar to `obyte.js` and `evm-chain.js`, use it in `transfers.js`, and deploy the agents.\n\nIn all cases, you are welcome to submit PRs to add your work to this repo.\n\n## Running automated tests on autonomous agents\n```bash\nyarn test aas/test\n```\n\n## Running automated tests on smart contracts\nInstall and run Ganache. If using a command-line version of Ganache (ganache-cli), run it on port 7545 (the default is 8545). Then run\n```bash\ncd evm\nnpx truffle test\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyteball%2Fcounterstake-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbyteball%2Fcounterstake-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyteball%2Fcounterstake-bridge/lists"}