{"id":25394940,"url":"https://github.com/zeta-chain/protocol-contracts-solana","last_synced_at":"2025-10-30T20:30:30.450Z","repository":{"id":251807463,"uuid":"817008116","full_name":"zeta-chain/protocol-contracts-solana","owner":"zeta-chain","description":"solana interface contract for zetachain","archived":false,"fork":false,"pushed_at":"2025-02-11T10:29:43.000Z","size":289,"stargazers_count":6,"open_issues_count":11,"forks_count":4,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-02-11T11:30:32.649Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/zeta-chain.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-18T20:39:43.000Z","updated_at":"2025-02-11T10:27:37.000Z","dependencies_parsed_at":"2024-08-15T08:14:21.292Z","dependency_job_id":"2c2aa41a-f8d8-4c6d-9416-9fdcbbb470aa","html_url":"https://github.com/zeta-chain/protocol-contracts-solana","commit_stats":null,"previous_names":["zeta-chain/protocol-contracts-solana"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeta-chain%2Fprotocol-contracts-solana","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeta-chain%2Fprotocol-contracts-solana/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeta-chain%2Fprotocol-contracts-solana/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeta-chain%2Fprotocol-contracts-solana/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeta-chain","download_url":"https://codeload.github.com/zeta-chain/protocol-contracts-solana/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239048257,"owners_count":19573187,"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":[],"created_at":"2025-02-15T19:52:31.293Z","updated_at":"2025-10-30T20:30:30.445Z","avatar_url":"https://github.com/zeta-chain.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Solana Protocol Contracts\n\n**Note**: Mainnet-beta, testnet, devnet gateway program address:\n\n```\nZETAjseVjuFsxdRxo6MmTCvqFwb3ZHUx56Co3vCmGis\n```\n\nThe PDA account address (derived from seeds `b\"meta\"` and canonical bump) is\n\n```\n2f9SLuUNb7TNeM6gzBwT4ZjbL5ZyKzzHg1Ce9yiquEjj\n```\n\nThe PDA account address (derived from seeds `b\"rent-payer\")\n\n```\nAm1aA3XQciu3vMG6E9yLa2Y9TcTf2XB3D3akLtjVzu3L\n```\n\n**Important Note**: The keypair in this repository is public and is used only\nfor development purposes. It should not be used on testnet or mainnet\nenvironments.\n\n# Introduction\n\nThis repository hosts the smart contract (program) deployed on the Solana\nnetwork to enable ZetaChain's cross-chain functionality. It consists of a single\nprogram that supports the following actions:\n\n1. Users on the Solana network can send SOL to the program to deposit into\n   ZetaChain, with the option to invoke a ZetaChain EVM contract.\n2. Contracts on the ZetaChain EVM can withdraw SOL to users on the Solana\n   network.\n\n# Build and Test Instructions\n\nPrerequisites: a recent version of `rust` compiler and `cargo` package manger\nmust be installed. The program is built with the `anchor` framework so it needs\nto be installed as well; see\n[installation](https://www.anchor-lang.com/docs/installation)\n\nPlease install compatible Solana tools and anchor-cli before build, otherwise\nthe program will not be built successfully\n\n```bash\n$ cargo install --git https://github.com/coral-xyz/anchor avm --force\n\n$ avm install 0.31.0\n\n$ sh -c \"$(curl -sSfL https://release.anza.xyz/v2.1.0/install)\"\n```\n\nTo show the installed versions of the tools\n\n```bash\n$ solana --version\nsolana-cli 2.1.0\n\n$ rustc --version\nrustc 1.81.0\n\n$ anchor --version\nanchor-cli 0.31.1\n```\n\nTo build (this will require at least 2GB disk space)\n\n```bash\n$ anchor build\n```\n\nTo run the tests\n\n```bash\n$ anchor test\n```\n\nTo generate Go bindings for program's IDL Development environments : Localnet\n\n```bash\n$ make generate-dev\n```\n\nProduction environments : Mainnet,Testnet\n\n```bash\n$ make generate-prod\n```\n\n# Authentication and Authorization\n\nAnyone can deposit and remote invoke ZetaChain contracts.\n\nOnly ZetaChain TSS account can call `withdraw` on the program. The ZetaChain TSS\naccount is a collection of Observer/Signers which uses ECDSA TSS (Threshold\nSignature Scheme) to sign outbound transactions. The TSS address will appear in\nthis program a single ECDSA secp256k1 address; but it does not have a single\nprivate key, rather its private key consists of multiple key shares and they\ncollectively sign a message in a KeySign MPC ceremony. The program authenticates\nvia verifying the TSS signature and is authorized by ZetaChain to perform\noutbound transactions as part of ZetaChain cross-chain machinery.\n\nThe ZetaChain TSS is on ECDSA secp256k1 curve; But Solana native digital\nsignature scheme is EdDSA Ed25519 curve. Therefore the program uses custom logic\nto verify the TSS ECDSA signature (like alternative authentication in smart\ncontract wallet); the native transaction signer (fee payer on Solana) does not\ncarry authorization and it's only used to build the transaction and pay tx fees.\nThere are no restrictions on who the native transaction signer/fee payer is. The\nfollowing code excerpt is for authenticating TSS signature in the contract\nitself, using the [Rust secp256k1 library bundled with\nsolana](https://docs.rs/solana-program/latest/solana_program/secp256k1_recover/index.html):\nhttps://github.com/zeta-chain/protocol-contracts-solana/blob/01eeb9733a00b6e972de0578b0e07ebc5837ec54/programs/protocol-contracts-solana/src/lib.rs#L116-L121\n\nThe function `recover_eth_address` is implemented in the gateway program:\nhttps://github.com/zeta-chain/protocol-contracts-solana/blob/01eeb9733a00b6e972de0578b0e07ebc5837ec54/programs/protocol-contracts-solana/src/lib.rs#L180-L196\n\nThe TSS signature is a ECDSA secp256k1 signature; its public key therefore\naddress (Ethereum compatible hashing from pubkey) is therefore verifiable using\nthe `secp256k1_recover` function. Alternatively, Solana runtime also provides a\nprogram to provide this verification service via CPI; see [proposal\n48](https://github.com/solana-foundation/solana-improvement-documents/blob/main/proposals/0048-native-program-for-secp256r1-sigverify.md)\nwhich might be more cost efficient.\n\nIn the instruction, the ECDSA signed message*hash must commit to the `nonce`,\n`amount`, and `to` address. See the check in these instructions like:\nhttps://github.com/zeta-chain/protocol-contracts-solana/blob/01eeb9733a00b6e972de0578b0e07ebc5837ec54/programs/protocol-contracts-solana/src/lib.rs#L110-L114\nThe commitment of `nonce` in the signature prevents replay of the TSS ECDSA\nsigned message. Also (to be added in\nhttps://github.com/zeta-chain/protocol-contracts-solana/issues/6) a chain id of\nSolana should be added to the commitment of the message hash, so that the\nsignature cannot be replayed on \\_other blockchains* that potentially uses\nsimilar authentication (say in TON).\n\n# Relevant Account and Addresses\n\nThe Gateway program derives a PDA (Program Derived Address) with seeds `b\"meta\"`\nand canonical bump. This PDA account/address actually holds the SOL balance of\nthe Gateway program. For SPL tokens, the program stores the SPL token in PDA\nderived ATAs. For each SPL token (different mint account), the program creates\nan ATA from the PDA and the Mint (standard way of deriving ATA in Solana SPL\nprogram).\n\nThe PDA account itself is a data account that holds Gateway program state,\nnamely the following data types\nhttps://github.com/zeta-chain/protocol-contracts-solana/blob/01eeb9733a00b6e972de0578b0e07ebc5837ec54/programs/protocol-contracts-solana/src/lib.rs#L271-L275\n\nThe `nonce` is incremented on each successful withdraw transaction, and it's\nused to prevent replay of signed ECDSA messages. The `tss_address` is the TSS\naddress of ZetaChain (20Bytes, Ethereum style). `authority` is the one who can\nupdate the TSS address stored in PDA account. The `initialize` instruction sets\nnonce to 0.\n\n# Troubleshooting\n\n## MacOS error when running `anchor test` or `solana-test-validator`\n\nIf you see errors like\n\n```\nUnable to get latest blockhash. Test validator does not look started. Check \".anchor/test-ledger/test-ledger-log.txt\" for errors. Consider increasing [test.startup_wait] in Anchor.toml.\n```\n\nor\n\n```bash\n% solana-test-validator --reset\nLedger location: test-ledger\nLog: test-ledger/validator.log\nError: failed to start validator: Failed to create ledger at test-ledger: io error: Error checking to unpack genesis archive: Archive error: extra entry found: \"._genesis.bin\" Regular\n```\n\nThis is because the BSD tar program is not compatible with the GNU tar program.\n\nTo fix the issue: install GNU tar program using homebrew and export it's\nexecutable path in your `.zshrc` file:\n\n**Mac with Apple Silicon**\n\n```bash\nbrew install gnu-tar\n# Put this in ~/.zshrc\nexport PATH=\"/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH\"\n```\n\n**Intel-based Mac**\n\n```bash\nbrew install gnu-tar\n# Put this in ~/.zshrc\nexport PATH=\"/usr/local/opt/gnu-tar/libexec/gnubin:$PATH\"\n```\n\nsee\nhttps://solana.stackexchange.com/questions/4499/blockstore-error-when-starting-solana-test-validator-on-macos-13-0-1/16319#16319\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeta-chain%2Fprotocol-contracts-solana","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeta-chain%2Fprotocol-contracts-solana","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeta-chain%2Fprotocol-contracts-solana/lists"}