Mirroring https://github.com/hyperledger-solang/solang
|
|
преди 5 години | |
|---|---|---|
| .github | преди 5 години | |
| docs | преди 5 години | |
| examples | преди 5 години | |
| src | преди 5 години | |
| stdlib | преди 5 години | |
| tests | преди 5 години | |
| .gitignore | преди 6 години | |
| CODEOWNERS | преди 5 години | |
| CODE_OF_CONDUCT.md | преди 5 години | |
| CONTRIBUTING.md | преди 5 години | |
| Cargo.toml | преди 5 години | |
| Dockerfile | преди 5 години | |
| LICENSE-APACHE | преди 6 години | |
| LICENSE-MIT | преди 6 години | |
| MAINTAINERS.md | преди 5 години | |
| README.md | преди 5 години | |
| SECURITY.md | преди 5 години | |
| build.rs | преди 5 години | |
| clippy.toml | преди 5 години |
Welcome to Solang, a new Solidity compiler written in rust which uses llvm as the compiler backend. As a result, only the compiler front end needs to be written in rust.
Solang targets Substrate and ewasm.
Solang is under active development right now, and should be documented at the same time as the implementation. Please have a look at our documentation.
First build solang or use the docker image, then write the following to flipper.sol:
contract flipper {
bool private value;
constructor(bool initvalue) public {
value = initvalue;
}
function flip() public {
value = !value;
}
function get() public view returns (bool) {
return value;
}
}
Now run:
solang flipper.sol
Alternatively if you want to use the solang docker image, run:
docker run --rm -it -v $(pwd):/sources hyperledgerlabs/solang -v -o /sources /sources/flipper.sol
You will have a flipper.wasm and flipper.json. You can use these directly in the Polkadot UI, as if your smart contract was written using ink!.
This is the experimental WIP Vyper branch, fully valid syntax is not currently supported.
You may compile the following contract:
value: bool
@public
def __init__(initvalue: bool):
value = initvalue
@public
def flip():
value = not value
@public
def get() -> (bool):
return value
Note: global contract variables in Vyper are currently referenced as in Solidity (i.e. without
self.), this is not valid syntax and will be fixed in a future release.