Mirroring https://github.com/hyperledger-solang/solang

Lucas Steuernagel 002954d1d6 v0.3.1: Göttingen release (aka June release) (#1404) пре 2 година
.github a1913b6953 Bump Solana, Anchor and Ubuntu (#1389) пре 2 година
docs 002954d1d6 v0.3.1: Göttingen release (aka June release) (#1404) пре 2 година
examples d772fe4bf9 Read compiler configurations from toml (#1347) пре 2 година
integration d792d1fec2 increase timeout for tornado integration tests пре 2 година
solana-library 071bdf3fb3 Use anchor npm library rather than @solana/solidity (#1125) пре 2 година
solang-parser 002954d1d6 v0.3.1: Göttingen release (aka June release) (#1404) пре 2 година
src 7519e36e6d Fix undefined variable detection (#1409) пре 2 година
stdlib 16458a07c9 Move stdlib build output to target folder (#1403) пре 2 година
testdata 6d1d1f715a Update Address and Hash types to ink ABI v4 (#1363) пре 2 година
tests 7519e36e6d Fix undefined variable detection (#1409) пре 2 година
vscode 94cff8f1a5 add option to set trace level (#1393) пре 2 година
.dockerignore 3d9a197990 Rename scripts to build пре 4 година
.gitignore 01707781ad Substrate: `subxt` integration tests (#990) пре 2 година
.gitmodules c98dfd3fa7 Tornado cash on Substrate :rocket: (#1360) пре 2 година
.readthedocs.yaml b961ce1d26 Unbreak readthedocs build (#1304) пре 2 година
CHANGELOG.md 002954d1d6 v0.3.1: Göttingen release (aka June release) (#1404) пре 2 година
CODEOWNERS cf83e286b5 Followup regarding subxt test (#1381) пре 2 година
CODE_OF_CONDUCT.md 3d8f6ba7af Add standard repo files пре 5 година
CONTRIBUTING.md 3d8f6ba7af Add standard repo files пре 5 година
Cargo.toml 002954d1d6 v0.3.1: Göttingen release (aka June release) (#1404) пре 2 година
Dockerfile a1913b6953 Bump Solana, Anchor and Ubuntu (#1389) пре 2 година
LICENSE 9d35806f37 Update license file to reflect that Solang is Apache-2.0 only пре 4 година
MAINTAINERS.md 0cfb7f3de2 Add Cyrill to maintainers list (#917) пре 3 година
README.md a1913b6953 Bump Solana, Anchor and Ubuntu (#1389) пре 2 година
RELEASE_CHECKLIST.md 002954d1d6 v0.3.1: Göttingen release (aka June release) (#1404) пре 2 година
SECURITY.md 1ab0e6d503 Correct Hyperledger Defect Response link пре 4 година
build.rs 200560e189 Enable tests for stdlib (#1299) пре 2 година
clippy.toml bd48744e1f Reduce arguments passed around in sema by using ExprContext пре 3 година

README.md

Solang Logo

solang - Solidity Compiler for Solana and Substrate

Discord CI Documentation Status license LoC

Welcome to Solang, a new Solidity compiler written in rust which uses llvm as the compiler backend. Solang can compile Solidity for Solana and Substrate. Solang is source compatible with Solidity 0.8, with some caveats due to differences in the underlying blockchain.

Solang is under active development right now, and has extensive documentation.

Installation

Solang is available as a Brew cask for MacOS, with the following command:

brew install hyperledger/solang/solang

For other operating systems, please check the installation guide.

Simple examples

Build for Solana

Run the following command, selecting the flipper example available in Solang's repository:

solang compile --target solana examples/solana/flipper.sol

Alternatively if you want to use the solang container, run:

docker run --rm -it -v $(pwd):/sources ghcr.io/hyperledger/solang compile -v -o /sources --target solana /sources/solana/flipper.sol

This generates a file called flipper.json and flipper.so. In order to deploy the contract code to the account F1ipperKF9EfD821ZbbYjS319LXYiBmjhzkkf5a26rC, save the private key to the file flipper-keypair.json:

echo "[4,10,246,143,43,1,234,17,159,249,41,16,230,9,198,162,107,221,233,124,34,15,16,57,205,53,237,217,149,17,229,195,3,150,242,90,91,222,117,26,196,224,214,105,82,62,237,137,92,67,213,23,14,206,230,155,43,36,85,254,247,11,226,145]" > flipper-keypair.json

Now you can deploy the contract code using:

solana program deploy flipper.so

Now install @coral-xyz/anchor:

npm install @coral-xyz/anchor

Save the following to flipper.js:

const { readFileSync } = require('fs');
const anchor = require('@coral-xyz/anchor');

const IDL = JSON.parse(readFileSync('./flipper.json', 'utf8'));
const PROGRAM_SO = readFileSync('./flipper.so');

(async function () {
	const provider = anchor.AnchorProvider.env();

	const dataAccount = anchor.web3.Keypair.generate();

	const programId = new anchor.web3.PublicKey(IDL.metadata.address);

	const wallet = provider.wallet.publicKey;

	const program = new anchor.Program(IDL, programId, provider);

	await program.methods.new(wallet, true)
		.accounts({ dataAccount: dataAccount.publicKey })
		.signers([dataAccount]).rpc();

	const val1 = await program.methods.get()
		.accounts({ dataAccount: dataAccount.publicKey })
		.view();

	console.log(`state: ${val1}`);

	await program.methods.flip()
		.accounts({ dataAccount: dataAccount.publicKey })
		.rpc();

	const val2 = await program.methods.get()
		.accounts({ dataAccount: dataAccount.publicKey })
		.view();

	console.log(`state: ${val2}`);
})();

And now run:

export ANCHOR_WALLET=$HOME/.config/solana/id.json
export ANCHOR_PROVIDER_URL=http://127.0.0.1:8899
node flipper.js

Build for Substrate

Run the following command, selecting the flipper example available on Solang's repository:

solang compile --target substrate examples/substrate/flipper.sol

Alternatively if you want to use the solang container, run:

docker run --rm -it -v $(pwd):/sources ghcr.io/hyperledger/solang compile -v -o /sources --target substrate /sources/flipper.sol

You will have a file called flipper.contract. You can use this directly in the Contracts UI, as if your smart contract was written using ink!.

Tentative roadmap

Solang has a high level of compatibility with many blockchains. We are trying to ensure the compiler stays up to date with the newest Solidity syntax and features. In addition, we focus on bringing new performance optimizations and improve developer experience. Here is a brief description of what we envision for the next versions.

V0.4

Feature Status
Improve management over optimization passes Not started
Adopt single static assignment for code generation In progress
Support openzeppelin on Substrate target In progress
Provide Solidity -> Substrate porting guide Not started
Call Solidity from Solana's Rust contracts Not started
Tooling for calls between ink! <> solidity In progress
Provide CLI for node interactions In progress

License

Apache 2.0