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

Sean Young 53172f3ad3 v0.3.0 Venice (#1319) vor 2 Jahren
.github 200560e189 Enable tests for stdlib (#1299) vor 2 Jahren
docs 53172f3ad3 v0.3.0 Venice (#1319) vor 2 Jahren
examples 91da9f3ae3 Fix flipper.sol example (#1206) vor 2 Jahren
integration f85e43ba64 Update substrate-contracts-node to v0.25.0 (#1300) vor 2 Jahren
solana-library 071bdf3fb3 Use anchor npm library rather than @solana/solidity (#1125) vor 2 Jahren
solang-parser 53172f3ad3 v0.3.0 Venice (#1319) vor 2 Jahren
src a09b8b9c02 solc does not warn or error for duplicate @param tags (#1320) vor 2 Jahren
stdlib 15d92e9169 Add padding in account deserialization (#1306) vor 2 Jahren
testdata a1e7ccade9 Use solc v0.8.20 testdata (#1310) vor 2 Jahren
tests a09b8b9c02 solc does not warn or error for duplicate @param tags (#1320) vor 2 Jahren
vscode 1a47714956 `this` is not a keyword (#1317) vor 2 Jahren
.dockerignore 3d9a197990 Rename scripts to build vor 4 Jahren
.gitignore 0344a87cf8 Feature ink metadata for substrate (#989) vor 3 Jahren
.gitmodules 12e3422596 Run Ethereum Solidity semantic tests through sema (#1279) vor 2 Jahren
.readthedocs.yaml b961ce1d26 Unbreak readthedocs build (#1304) vor 2 Jahren
CHANGELOG.md 53172f3ad3 v0.3.0 Venice (#1319) vor 2 Jahren
CODEOWNERS 43cdc7ee15 Expand list of code owners, take #2 (#1176) vor 2 Jahren
CODE_OF_CONDUCT.md 3d8f6ba7af Add standard repo files vor 5 Jahren
CONTRIBUTING.md 3d8f6ba7af Add standard repo files vor 5 Jahren
Cargo.toml 53172f3ad3 v0.3.0 Venice (#1319) vor 2 Jahren
Dockerfile 48571b19d6 Compare the full 64 bits address on Solana (#1295) vor 2 Jahren
LICENSE 9d35806f37 Update license file to reflect that Solang is Apache-2.0 only vor 4 Jahren
MAINTAINERS.md 0cfb7f3de2 Add Cyrill to maintainers list (#917) vor 3 Jahren
README.md 53172f3ad3 v0.3.0 Venice (#1319) vor 2 Jahren
RELEASE_CHECKLIST.md 53172f3ad3 v0.3.0 Venice (#1319) vor 2 Jahren
SECURITY.md 1ab0e6d503 Correct Hyperledger Defect Response link vor 4 Jahren
build.rs 200560e189 Enable tests for stdlib (#1299) vor 2 Jahren
clippy.toml bd48744e1f Reduce arguments passed around in sema by using ExprContext vor 3 Jahren

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 @project-serum/anchor:

npm install @project-serum/anchor

Save the following to flipper.js:

const { readFileSync } = require('fs');
const anchor = require('@project-serum/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 Not started
Support openzeppelin on Substrate target Not started
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 Not started

License

Apache 2.0