/examples

Code samples inspiring language design

Primary LanguageIdris

Sample Idris Ethereum smart contracts

Example contracts to show how to use Idris as a smart contract language for the Ethereum platform.

Prerequisites

For compiling to actual EVM code (not yet fully possible due to back end output size), you need either:

  • pyethereum (for running Serpent code in a simulator), or
  • An Ethereum client like AlethZero to compile the LLL code

Building

For example, building the Rock-Paper-Scissors sample. Assuming idris-se and examples are checked out in the same directory.

Compiling to Serpent and then to LLL:

idris -p effects -p contrib idris/RPS_SIO.idr -i idris/ -i ../idris-se/lib --codegen se --interface -o rps.se --no-partial-eval
serpent compile_to_lll rps.se > rps.lll

Run using the test runner (should work):

idris -p effects -p contrib idris/RPS_IO.idr -i ../idris-se/lib -i idris  -o rps --no-partial-eval && ./rps