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 (Ethereum, Solana, Substrate)
- More mature project with a larger community and ecosystem
- Better documentation and tooling support
Cons of Solang
- Steeper learning curve due to more complex features
- May introduce overhead for simpler smart contract projects
- Less focus on Ethereum-specific optimizations
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;
}
}
Summary
Fe is a newer, Ethereum-focused language with a simpler syntax and potentially easier onboarding for Rust developers. Solang offers broader blockchain support and a more established ecosystem but may be more complex for beginners. Fe's syntax is more Rust-like, while Solang closely resembles Solidity. Both aim to improve smart contract development, with Fe focusing on Ethereum-specific optimizations and Solang providing cross-platform compatibility.
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: Most of the master
branch will be replaced with a 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). The type system is similar to rust's, with the addition of higher-kinded types (on the fe-v2
branch). We're exploring additional type system, syntax, and semantic changes. Please note that the current docs reflect the status of the language on the master
branch.
Progress
Fe has had several early releases which can be used today, though these releases are lacking some features and don't reflect our complete vision for the language. The current focus is on finishing the fe-v2
branch, and development of the sonatina compiler backend which Fe will use.
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()
}
}
More 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:
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