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

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

Gerald,

This is very interesting - I have been lukewarm about learning solidity but this avenue might motivate me!

Regards,

Phil.

···

On 2019-02-20 03:59, Gerald Bauer wrote:

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] GitHub - learnpixelart/pixelart.js: pixelart.js

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
Philip Rhoades

PO Box 896
Cowra NSW 2794
Australia
E-mail: phil@pricom.com.au

Hello,

  Thanks for your kind words. The "classic" starter guide for Solidity
is the CryptoZombies (free online) code school [1].

   Another (great) alternative language for Solidity with Python
3-Compatible Syntax :slight_smile: is the Vyper languague [2].

   For secure ruby (sruby) I'm trying to put together a (free online)
programming crypto contracts step-by-step guide / booklet [3]. You can
run all ruby contract samples with "standard" ruby (only requires the
universum library / gem - no test network needed - it's kind of a
simulator / emulator).

   Cheers. Prost.

[1] https://cryptozombies.io
[2] https://vyper.readthedocs.io
[3] https://github.com/s6ruby/programming-cryptocontracts