A collection of vigorously tested, examplary Huff contracts for demonstration purposes.

Related tags

React huff-examples
Overview

The Huff Programming Language

Huff logo.

Huff is a low-level programming language designed for developing highly optimized smart contracts that run on the Ethereum Virtual Machine (EVM). Huff does not hide the inner workings of the EVM. Instead, Huff exposes its programming stack to the developer for manual manipulation.

Rather than having functions, Huff has macros - individual blocks of bytecode that can be rigorously tested and evaluated using the Huff runtime testing suite.

Initially developed by the Aztec Protocol team, Huff was created to write Weierstrudel. Weierstrudel is an on-chain elliptical curve arithmetic library that requires incredibly optimized code that neither Solidity nor Yul could provide.

While EVM experts can use Huff to write highly-efficient smart contracts for use in production, it can also serve as a way for beginners to learn more about the EVM.

Example

Prerequisities

Make sure you have the following programs installed:

Steps

This is how to create the contract bytecode to output Hello, World! in Huff.

  1. Install Huff globally:

    yarn global add huffc

Note: You may need to add yarn to your system's path to access globally installed packages. See the yarn docs on global for more details.

  1. Create a file called hello-world.huff and enter the following content:

    #define macro MAIN() = takes (0) returns (0) {
        0x48656c6c6f2c20776f726c6421 0x00 mstore // Store "Hello, World!" in memory.
        0x1a 0x00 return // Return 26 bytes starting from memory pointer 0.
    }
  2. Use huffc to compile the contract and output bytecode:

    huffc hello-world.huff --bytecode

    This will output something like:

    6100168061000d6000396000f36c48656c6c6f2c20776f726c6421600052601a6000f3 
    

More help

Run huffc --help to view a full list of arguments:

huffc --help

> Usage: huffc [options]
> 
> Options:
>   -V, --version                    output the version number
>   -V, --version                    Show the version and exit
>   --base-path <path>               The base path to the contracts (default: "./")
>   --output-directory <output-dir>  The output directory (default: "./")
>   --bytecode                       Generate and log bytecode (default: false)
>   -o, output                       The output file
>   -p, --paste                      Paste the output to the terminal
>   -h, --help                       display help for command
You might also like...

Collection of Animated 60 FPS TabBar Component's based on React Navigation.

Collection of Animated 60 FPS TabBar Component's based on React Navigation.

React Navigation TabBar Collection Collection of Animated 60 FPS TabBar Components based on React Navigation. Features 60 FPS Animation Beautiful TabB

Dec 9, 2022

Is a collection of utils for the system, directories, deno and files informations :p

Is a collection of utils for the system, directories, deno and files informations :p

Is a collection of utils for the system, directories, deno and files informations :p

Jul 22, 2022

A collection of framework specific Auth utilities for working with Supabase.

A collection of framework specific Auth utilities for working with Supabase.

Jan 2, 2023

Nextjs-components: A collection of React components

Nextjs-components: A collection of React components

nextjs-components A collection of React components, transcribed from https://vercel.com/design. 1 Motivation Blog post from 01/09/2022 Todo's Unit tes

Nov 30, 2022

Our Expo-based mobile application for demonstration purposes.

Capable Care reference implementation This repository provides a working example of a React Native mobile application (built on Expo) integrating Capa

Oct 1, 2022

A simple NFT trading and breeding platform for demonstration purposes.

A simple NFT trading and breeding platform for demonstration purposes.

📦 boxyz I know it sounds strange, but maybe these boxes can breed and have children. They can be sold as well. boxyz is a fun project to trade and br

Dec 12, 2022

This repo is for educational and demonstration purposes only, this project is to demonstrate usage of apollo/client and github API and firebase.

This repo is for educational and demonstration purposes only, this project is to demonstrate usage of apollo/client and github API and firebase.

Gissues Gissues is a web application that allows you to search for issues in GitHub. It is built for new developers who want to learn more about GitHu

Oct 1, 2022

An npm package for demonstration purposes using TypeScript to build for both the ECMAScript Module format (i.e. ESM or ES Module) and CommonJS Module format. It can be used in Node.js and browser applications.

An npm package for demonstration purposes using TypeScript to build for both the ECMAScript Module format (i.e. ESM or ES Module) and CommonJS Module format. It can be used in Node.js and browser applications.

Dec 28, 2022

Project developed in typescript with clean architecture + tdd for demonstration purposes.

Description Project developed in typescript with clean architecture + tdd for demonstration purposes in Usystem. Installation $ yarn Running the app #

Oct 5, 2022

Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

May 18, 2022

Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

May 3, 2022

Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

Jan 3, 2023

Main Site for the Huff Language.

Huff UI A simple landing page for the Huff Language. Get Started Install yarn if you haven't already: npm i -g yarn Install dependencies and start the

Jul 26, 2022

WIP: Hevm based debugger for hardhat-huff projects

Huff Debug An easy hevm debug integration for hardhat-huff projects What does it do: Speed up your development experience by gaining rich feedback in

Jul 15, 2022

A collection of smart contracts for the Stackup platform 🤖 📑

Contracts A collection of smart contracts for the Stackup platform. Dev Blog Deployed Contracts See releases for deployed contracts of previous versio

Nov 29, 2021

This is the main repository for NFT collection dao smart contracts.

Basic Sample Hardhat Project This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, a sample s

Apr 11, 2022

Demonstration of different animation effects with AngularJS ngView directive.

ngView-animation-effects This is a simple demonstration of how easy you can make your ngView directive transition pages with nice animations. All you

Dec 31, 2022

Demonstration of how to use statecharts as and with actors in Ember.js

statechart-actors This app demonstrate how we can use ember-statecharts and XState's actor feature together. The demo-use case: Show a blog posts over

Jan 9, 2022

Demonstration of how you build full-stack, typed, NPM packages, the right way

NPM Packages - The Right way This repository aims to demonstrate how to build NPM packages the right way. my-package should import the shared code, bu

Nov 27, 2022
Comments
  • Create a Variety of Simple Web3 Protocols/Apps

    Create a Variety of Simple Web3 Protocols/Apps

    Based off of this repo: https://github.com/m1guelpf/lil-web3 , implement huff contract examples for each concept. These concepts include but may not be limited to DIY implementations of:

    • ENS
    • OpenSea
    • Fractional
    • Juicebox
    • Gnosis Safe
    • Flashloans
    • Superfluid
    opened by pynchmeister 1
  • fix: remove unused constant

    fix: remove unused constant

    This pr removes the unused ALLOWANCE_LOCATION constant in ERC20.

    https://discord.com/channels/980519274600882306/980576949808300082/981226803370815518

    opened by devtooligan 0
  • Update README

    Update README

    This repo still has the README from huffc. We should probably add a simple set of instructions for how to setup a new huff project using the template and a guide for how to add an example project to this repo.

    opened by d1ll0n 0
Owner
Huff
Huff is a low level assembly language for the Ethereum Virtual Machine
Huff
This repo is for educational and demonstration purposes only, this project is to demonstrate usage of apollo/client and github API and firebase.

Gissues Gissues is a web application that allows you to search for issues in GitHub. It is built for new developers who want to learn more about GitHu

Shikhar 10 Oct 1, 2022
Demonstration of how to use statecharts as and with actors in Ember.js

statechart-actors This app demonstrate how we can use ember-statecharts and XState's actor feature together. The demo-use case: Show a blog posts over

Michael Klein 3 Jan 9, 2022
trying to clone tiktok using next, typescript, tailwindcss and hasura graphql. For educational purposes only

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

null 2 Jan 4, 2022
Using Ethereum Smart Contracts to verify any user's vaccination via Identification Number or QR Code.

Covid-Vaccine-Verification-Blockchain Using Ethereum Smart Contracts to verify any user's vaccination via Identification Number or QR Code. Requiremen

Zaynab Batool Reza 4 May 14, 2022
This box comes with everything you need to start using smart contracts from a react app

Truffle React Hooks TypeScript Template This box comes with everything you need to start using smart contracts from a react app. This is as barebones

Louis Aussedat 3 Mar 11, 2022
Examples of Solidity++ contracts

soliditypp-examples Examples of Solidity++ 0.8.0 / 0.8.1. This is a preview version. DO NOT use it in production environment. Getting Started npm inst

Vite Labs 8 Sep 18, 2022
A collection of composable React components for building interactive data visualizations

an ecosystem of composable React components for building interactive data visualizations. Victory Contents Getting Started Victory Native API Document

Formidable 10.1k Jan 3, 2023
A collection of sample apps built using GetStream and React Native

React Native samples [ Built with ♥ at Stream ] This repo contains projects and samples developed by the team and Stream community, using React Native

Stream 93 Jan 8, 2023
use this to replace redux,you can use useActions to change context value and useActions return a mutable function collection

English | 中文 NOTE react-context-mutation is a lighter and more convenient state manager designed for react applications. It aims to replace the Redux

null 19 Feb 22, 2022
A collection of free logos for open source projects

Libre Logos Libre Logos is a library of free logos. The logos are intended for open source projects and NGOs. Designers are invited to contribute. The

E. Cleopatra 144 Nov 11, 2022