Top Related Projects
Quick Overview
Fe is an emerging statically typed language for the Ethereum Virtual Machine (EVM). It aims to be simple and safe, drawing inspiration from Python and Rust while focusing on features specific to smart contract development. Fe is designed to make it easier for developers to write secure and efficient smart contracts for Ethereum and other EVM-compatible blockchains.
Pros
- Statically typed, providing better safety and catching errors at compile-time
- Syntax inspired by Python, making it easier for developers familiar with Python to transition
- Built-in security features tailored for smart contract development
- Compiles directly to EVM bytecode, potentially offering better performance than Solidity
Cons
- Still in early development, not yet ready for production use
- Limited ecosystem and tooling compared to more established languages like Solidity
- Smaller community and fewer learning resources available
- May require developers to learn a new language if they're already familiar with Solidity
Code Examples
- Basic contract structure:
contract SimpleStorage {
value: u256
pub fn set_value(self, new_value: u256) {
self.value = new_value
}
pub fn get_value(self) -> u256 {
return self.value
}
}
- Event emission:
contract EventEmitter {
pub event ValueChanged {
old_value: u256
new_value: u256
}
value: u256
pub fn change_value(self, new_value: u256) {
let old_value: u256 = self.value
self.value = new_value
emit ValueChanged(old_value, new_value)
}
}
- Using structs and mappings:
struct User {
pub name: String<100>
pub balance: u256
}
contract UserRegistry {
users: Map<address, User>
pub fn register_user(self, name: String<100>) {
let new_user: User = User(name, 0)
self.users[msg.sender] = new_user
}
pub fn get_user(self, addr: address) -> User {
return self.users[addr]
}
}
Getting Started
To get started with Fe, follow these steps:
- Install Rust and Cargo (Fe is written in Rust)
- Install Fe using Cargo:
cargo install fe
- Create a new Fe project:
fe new my_project cd my_project
- Compile your Fe code:
fe build
Note that Fe is still in development, so features and syntax may change. Always refer to the official documentation for the most up-to-date information.
Competitor Comparisons
Polkadot's ink! to write smart contracts.
Pros of ink
- More mature and widely adopted in the Polkadot ecosystem
- Extensive documentation and community support
- Built-in testing framework for easier contract testing
Cons of ink
- Limited to Substrate-based chains, less versatile than Fe
- Steeper learning curve for developers not familiar with Rust
- Smaller ecosystem compared to Ethereum-based smart contracts
Code Comparison
Fe:
contract Token:
balances: map<address, u256>
pub fn transfer(self, to: address, amount: u256):
self.balances[msg.sender] -= amount
self.balances[to] += amount
ink:
#[ink(storage)]
pub struct Token {
balances: ink_storage::Mapping<AccountId, Balance>,
}
impl Token {
#[ink(message)]
pub fn transfer(&mut self, to: AccountId, amount: Balance) {
let from = self.env().caller();
self.balances.insert(from, self.balances.get(&from).unwrap_or(0) - amount);
self.balances.insert(to, self.balances.get(&to).unwrap_or(0) + amount);
}
}
The code comparison shows that Fe uses a more Python-like syntax, which may be easier for some developers to read and write. ink, being Rust-based, offers stronger type safety and memory management but may require more verbose code.
Solidity Compiler for Solana and Polkadot
Pros of Solang
- Supports multiple blockchain platforms (Solana, Ethereum, Substrate)
- More mature project with a larger community and ecosystem
- Extensive documentation and examples available
Cons of Solang
- Steeper learning curve due to its multi-platform nature
- May have more complexity in the codebase to support various platforms
- Potentially slower compilation times for large projects
Code Comparison
Fe:
contract Counter {
count: u256
pub fn increment(mut self) {
self.count += 1
}
pub fn get(self) -> u256 {
return self.count
}
}
Solang:
contract Counter {
uint256 private count;
function increment() public {
count += 1;
}
function get() public view returns (uint256) {
return count;
}
}
Key Differences
- Fe uses Rust-like syntax, while Solang uses Solidity syntax
- Fe has explicit mutability with
mut self
, Solang relies on function visibility - Fe uses
u256
for unsigned integers, Solang usesuint256
- Fe's
return
keyword is optional, Solang requires it
Both projects aim to improve smart contract development, but Fe focuses on Ethereum-like chains with a Rust-inspired syntax, while Solang targets multiple platforms with a Solidity-like language.
Pythonic Smart Contract Language for the EVM
Pros of Vyper
- More mature and widely adopted in the Ethereum ecosystem
- Simpler syntax, designed for readability and auditability
- Stronger safety features, including bounds and overflow checking
Cons of Vyper
- Limited support for complex data structures
- Slower compilation times compared to Fe
- Less flexible, with intentional restrictions on certain programming patterns
Code Comparison
Vyper:
@external
def transfer(to: address, amount: uint256) -> bool:
self.balanceOf[msg.sender] -= amount
self.balanceOf[to] += amount
log Transfer(msg.sender, to, amount)
return True
Fe:
pub fn transfer(self, to: address, amount: u256) -> bool {
self.balance_of[msg.sender] -= amount;
self.balance_of[to] += amount;
emit Transfer(msg.sender, to, amount);
true
}
Both languages aim to provide safer smart contract development for Ethereum. Vyper focuses on simplicity and readability, while Fe offers a more Rust-like syntax with additional features. Vyper has been around longer and has more adoption, but Fe is gaining traction with its modern language design. The choice between them often depends on the developer's preference and project requirements.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Fe is an emerging smart contract language for the Ethereum blockchain.
NOTE: The larger part of the master
branch will be replaced with the brand-new implementation, which is currently under development in the fe-v2 branch. Please refer to the branch if you kindly contribute to Fe
Overview
Fe is a statically typed language for the Ethereum Virtual Machine (EVM). It is inspired by Rust and easy to learn -- especially for new developers entering the Ethereum ecosystem.
Features & Goals
- Bounds and overflow checking
- Decidability by limitation of dynamic program behavior
- More precise gas estimation (as a consequence of decidability)
- Static typing
- Pure function support
- Restrictions on reentrancy
- Static looping
- Module imports
- Standard library
- Usage of YUL IR to target both EVM and eWASM
- WASM compiler binaries for enhanced portability and in-browser compilation of Fe contracts
- Implementation in a powerful, systems-oriented language (Rust) with strong safety guarantees to reduce risk of compiler bugs
Additional information about design goals and background can be found in the official announcement.
Language Specification
We aim to provide a full language specification that should eventually be used to formally verify the correctness of the compiler. A work in progress draft of the specification can be found here.
Progress
Fe development is still in its early stages. We have a basic Roadmap for 2021 that we want to follow. We generally try to drive the development by working through real world use cases. Our next goal is to provide a working Uniswap implementation in Fe which will help us to advance and form the language.
Fe had its first alpha release January 2021 and is now following a monthly release cycle.
Getting started
To compile Fe code:
- Run
fe path/to/fe_source.fe
- Fe creates a directory
output
in the current working directory that contains the compiled binary and abi.
Run fe --help
to explore further options.
Examples
The following is a simple contract implemented in Fe.
struct Signed {
pub book_msg: String<100>
}
contract GuestBook {
messages: Map<address, String<100>>
pub fn sign(mut self, mut ctx: Context, book_msg: String<100>) {
self.messages[ctx.msg_sender()] = book_msg
ctx.emit(Signed(book_msg: book_msg))
}
pub fn get_msg(self, addr: address) -> String<100> {
return self.messages[addr].to_mem()
}
}
A lot more working examples can be found in our test fixtures directory.
The most advanced example that we can provide at this point is an implementation of the Uniswap-V2 core contracts.
Community
- Twitter: @official_fe
- Chat: Discord
License
The Fe implementation is split into several crates. Crates that depend on the
solidity compiler (directly or indirectly) are licensed GPL-3.0-or-later. This
includes the fe
CLI tool, yulc, driver, tests, and test-utils.
The remaining crates are licensed Apache-2.0. This includes the parser, analyzer, mir, abi, and common.
Top Related Projects
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot