(Secure) Ruby to Solidity (Source-to-Source) Cross-Compiler Cheat Sheet / White Paper

Gerald Bauer <[email protected]>
Newsgroups gmane.comp.lang.ruby.general
Message-ID <CAAxEZd9r=C5_zzOMF1uRJjfRPD02vSyTA+=MK6_U3L0JEt+3Nw@mail.gmail.com>
Hello,

  I've started a new white paper / cheat sheet on
  a (secure) ruby to solidity (source-to-source) cross-compiler [1].

  If anyone is interested in how to turn ruby into solidity (and
ethereum virtual machine (evm) bytecode) let us know!
  Question or comments welcome. Yes, the ruby-talk mailing list
  right here is the "official" sruby channel.

  Cheers. Prost.

PS: Here's a first example:

```
############################
# My Token Contract

# @sig (uint256) public
def setup( initial_supply )
  @balance_of = Mapping.of( Address => Money )
  @balance_of[ msg.sender] = initial_supply
end

# @sig (address, uint256) public returns (bool)
def transfer( to, value )
  assert @balance_of[ msg.sender ] >= value
  assert @balance_of[ to ] + value >= @balance_of[ to ]

  @balance_of[ msg.sender ] -= value
  @balance_of[ to ]         += value

  true
end
```

gets cross-compiled to:

```
contract MyToken {
    mapping (address => uint256) public balanceOf;

    constructor( uint256 _initialSupply ) public {
        balanceOf[msg.sender] = _initialSupply;
    }

    function transfer(address _to, uint256 _value) public returns (bool) {
        require(balanceOf[msg.sender] >= _value);
        require(balanceOf[_to] + _value >= balanceOf[_to]);

        balanceOf[msg.sender] -= _value;
        balanceOf[_to]        += _value;

        return true;
    }
}
```

Note: For now there's no magic type inference for function signatures
- you MUST annotate all ruby functions.

[1] https://github.com/s6ruby/solidity

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.