hyperledger-solang/solang

GitHub: hyperledger-solang/solang

一个用Rust编写的Solidity跨链编译器,支持将Solidity代码编译为Solana、Polkadot和Stellar Soroban智能合约。

Stars: 1374 | Forks: 253

Solang Logo # solang - 适用于 Solana、Polkadot 和 Soroban 的 Solidity 编译器 [![Discord](https://img.shields.io/discord/905194001349627914?logo=Hyperledger&style=plastic)](https://discord.gg/hyperledger) [![CI](https://github.com/hyperledger-solang/solang/workflows/test/badge.svg)](https://github.com/hyperledger-solang/solang/actions) [![文档状态](https://readthedocs.org/projects/solang/badge/?version=latest)](https://solang.readthedocs.io/en/latest/?badge=latest) [![license](https://img.shields.io/github/license/hyperledger/solang.svg)](LICENSE) [![LoC](https://tokei.rs/b1/github/hyperledger/solang?category=lines)](https://github.com/hyperledger-solang/solang) 欢迎使用 Solang,这是一个用 Rust 编写的新 Solidity 编译器,使用 llvm 作为编译器后端。Solang 可以为 Solana、Soroban 以及带有 `contracts` pallet 的 Polkadot 平行链编译 Solidity。 Solang 与 Solidity 0.8 源码兼容, 但由于底层区块链的差异,存在一些注意事项。 Solang 目前正处于活跃开发阶段,并拥有 [详尽的文档](https://solang.readthedocs.io/en/latest/)。 ## Solana 请遵循 [Solang 入门指南](https://solana.com/developers/guides/solang/getting-started)。 Solang 是 [Solana 工具套件](https://docs.solana.com/cli/install-solana-cli-tools)的一部分(v1.16.3 及更高版本)。 无需单独安装。 ## 安装 Solang 以 Brew cask 形式提供给 MacOS,使用以下命令: ``` brew install hyperledger/solang/solang ``` 对于其他操作系统,请查看[安装指南](https://solang.readthedocs.io/en/latest/installing.html)。 ## 为 Polkadot 构建 运行以下命令,选择 Solang 仓库中提供的 flipper 示例: ``` solang compile --target polkadot examples/polkadot/flipper.sol ``` 或者,如果您想使用 solang 容器,请运行: ``` docker run --rm -it -v $(pwd):/sources ghcr.io/hyperledger/solang compile -v -o /sources --target polkadot /sources/flipper.sol ``` 您将获得一个名为 flipper.contract 的文件。您可以直接在 [Contracts UI](https://contracts-ui.substrate.io/) 中使用它, 就像您的智能合约是用 ink! 编写的一样。 ## 为 Soroban 构建 选择 Solang 仓库中提供的 Soroban 支持合约之一: ``` solang compile --target soroban examples/soroban/token.sol ``` 您将获得一个名为 `token.wasm` 的文件。按照 [`Stellar CLI 设置手册`](https://developers.stellar.org/docs/build/smart-contracts/getting-started/setup) 操作后,使用 [`Stellar CLI`](https://developers.stellar.org/docs/tools/cli) 部署它: ``` stellar contract deploy --source-account alice --wasm token.wasm --network testnet -- --_admin alice --_name SolangToken --_symbol SOLT --_decimals 18 ℹ️ Skipping install because wasm already installed ℹ️ Using wasm hash b1c84d8b8057a62fb6d77ef55c9e7fb2e66c74136c7df32efd87a1c9d475f1b0 ℹ️ Simulating deploy transaction… ℹ️ Transaction hash is fc3b1f00d2940e646d210e6e96347fd45dc8dd873009604ec67957edb6f6589d 🔗 https://stellar.expert/explorer/testnet/tx/fc3b1f00d2940e646d210e6e96347fd45dc8dd873009604ec67957edb6f6589d ℹ️ Signing transaction: fc3b1f00d2940e646d210e6e96347fd45dc8dd873009604ec67957edb6f6589d 🌎 Submitting deploy transaction… 🔗 https://stellar.expert/explorer/testnet/contract/CDGUMUXA6IRRVMMKIVQJWLZZONDXBJ4AITHQS757PTBVAL4U54HI3KEW ✅ Deployed! CDGUMUXA6IRRVMMKIVQJWLZZONDXBJ4AITHQS757PTBVAL4U54HI3KEW ``` 部署完成后,复制已部署的合约 ID 并与其交互: ``` stellar contract invoke --network testnet --id CDGUMUXA6IRRVMMKIVQJWLZZONDXBJ4AITHQS757PTBVAL4U54HI3KEW --source-account alice -- mint --to alice --amount 120 ℹ️ Signing transaction: e0d68ae85bfbe0fceed8bcadd6613e12b3159f27dbf7c18e35e94de2b4a11ee2 ``` ## 初步路线图 Solang 与许多区块链具有高度的兼容性。我们正在努力确保编译器保持 与最新的 Solidity 语法和功能同步。此外,我们专注于引入新的性能优化 并改善开发者体验。 以下是我们对未来版本的简要构想。 ### V0.4 | 功能 | 状态 | |----------------------------------------------------|------------------------------------------------------| | 改进优化 pass 的管理 | 尚未开始 | | 在代码生成中采用单静态赋值 | 进行中 | | 在 Polkadot 目标上支持 openzeppelin | 进行中 | | 提供 Solidity -> Polkadot 移植指南 | 尚未开始 | | 在 Solana 上为 Solidity 函数声明账户 | 进行中 | | ink! <> solidity 之间调用的工具 | 进行中 | | 提供用于节点交互的 CLI | [已完成](https://github.com/hyperledger-solang/solang-aqd) | | 支持所有 [Soroban 示例](https://github.com/stellar/soroban-examples) | 进行中 | ## 许可证 [Apache 2.0](LICENSE)
标签:Hyperledger, LLVM, Parachain, Polkadot, Rust, Solana, Solang, Solidity, Soroban, Stellar, substrate, Web3, 代码编译, 区块链, 去中心化, 可视化界面, 威胁情报, 开发者工具, 智能合约, 编程语言, 编译器, 网络流量审计, 请求拦截, 跨链, 通知系统, 通知系统