Solang Solidity Compiler
Welcome to the Solang Solidity Compiler. Using Solang, you can compile smart contracts written in Solidity for Solana and Polkadot. It uses the llvm compiler framework to produce WebAssembly (WASM) or Solana SBF contract code. As result, the output is highly optimized, which saves you in gas costs or compute units.
Solang aims for source file compatibility with the Ethereum EVM Solidity compiler, version 0.8. Where differences exist, this is noted in the language documentation. The source code repository can be found on github and we have solang channels on Hyperledger Discord.
Contents
- Solana
- Solana Overview
- Getting started on Solana
- Using the Anchor client library
- Calling Anchor Programs from Solidity
- Setting the program_id for a contract
- Setting the payer, seeds, bump, and space for a contract
- Transferring native value with a function call
- Receive function
msg.sender
not available on Solana- Builtin Imports
- Solana Library
- Solana Account Management
- Polkadot
- Brief Language status
- File Structure
- Imports
- Pragmas
- Types
- Expressions
- Statements
- Constants
Using
directive- Contracts
- Contract Storage
- Interfaces and libraries
- Events
- Functions
- Function visibility
- Arguments passing and return values
- Internal calls and externals calls
- Passing accounts with external calls on Solana
- Passing seeds with external calls on Solana
- Passing value and gas with external calls
- State mutability
- Overriding function selector
- Function overloading
- Function Modifiers
- Calling an external function using
call()
- Calling an external function using
delegatecall
- fallback() and receive() function
- Managing values
- Builtin Functions and Variables
- Block and transaction
- Error handling
- ABI encoding and decoding
- abi.decode(bytes, (type-list))
- abi.encode(…)
- abi.encodeWithSelector(selector, …)
- abi.encodeWithSignature(string signature, …)
- abi.encodePacked(…)
- abi.encodeCall(function, …)
- Hash
- chain_extension(uint32 ID, bytes input) returns (uint32, bytes)
- is_contract(address AccountId) returns (bool)
- caller_is_root() returns (bool)
- set_code_hash(uint8[32] hash) returns (uint32)
- Cryptography
- Mathematical
- Encoding and decoding values from bytes buffer
- readInt8(uint32 offset)
- readInt16LE(uint32 offset)
- readInt32LE(uint32 offset)
- readInt64LE(uint32 offset)
- readInt128LE(uint32 offset)
- readInt256LE(uint32 offset)
- readUint16LE(uint32 offset)
- readUint32LE(uint32 offset)
- readUint64LE(uint32 offset)
- readUint128LE(uint32 offset)
- readUint256LE(uint32 offset)
- readAddress(uint32 offset)
- writeInt8(int8 value, uint32 offset)
- writeInt16LE(int16 value, uint32 offset)
- writeInt32LE(int32 value, uint32 offset)
- writeInt64LE(int64 value, uint32 offset)
- writeInt128LE(int128 value, uint32 offset)
- writeInt256LE(int256 value, uint32 offset)
- writeUint16LE(uint16 value, uint32 offset)
- writeUint32LE(uint32 value, uint32 offset)
- writeUint64LE(uint64 value, uint32 offset)
- writeUint128LE(uint128 value, uint32 offset)
- writeUint256LE(uint256 value, uint32 offset)
- writeAddress(address value, uint32 offset)
- writeString(string value, uint32 offset)
- writeBytes(bytes value, uint32 offset)
- Miscellaneous
- Tags
- Inline Assembly