Guidance for Ruby Developers?

phironfuzephironfuze Posts: 2
Hi, still consider myself a newer ruby developer (1 year), any advice on what I should be learning in order to participate in Ethereum ? would appreciate any input thanks!

Comments

  • GeorgeHallamGeorgeHallam Posts: 229 admin
    edited June 2015
    Hi @phironfuze - a good place for a new developer to start is https://dappsforbeginners.wordpress.com/

    If you have any questions, feel free to add me on Skype (george_hallam), and I'll be happy to help you out :)
  • tym4ttym4t Nagata-ku, Kobe-shi, Hyogo-ken, JapanPosts: 71 ✭✭✭
    edited July 2015
    Most of the tools for developing Ethereum DApps is in JavaScript and Solidity. You can write some Ruby programs that talk to your geth/eth node via HTTP JSONRPC or IPC JSONRPC (for account controls) to do some simple queries on the blockchain for example:
    #!/usr/bin/env ruby
    require 'jsonrpc-client'
    require "active_support"
    require "active_support/core_ext"
    
    connection = JSONRPC::Client.new("http://localhost:8545")
    block_number = connection.eth_getBlockByNumber('latest', true)
    transaction = connection.eth_getTransactionByHash('0x7435A501BA8BF0B6F98A35D24034FC38D6F44E1EEC8A2DAEEC9A666C04245483')

    You can also send transactions through this interface but you will need to properly encode your transaction to call functions and send the required data. This would require figuring out the encoding process. It's basically a combination of figuring out the function signature which is the sha3 hash of:

    function(paramtype1,paramtype2) along with the hex encoded versions of the required data.

    You would then do:

    connection.eth_sendTransaction({to: contractAddress, from: connection.eth_coinbase["result"], code: encodedData}) (returns the transaction ID)

    You can then query the results by reading either the contract storage which can be decoded by reversing your encoding function.

    With this knowledge you can actually create a DSL that can read the JSON ABI and generate Ruby classes that when instantiated into objects can be used to call your Ethereum contracts. This is actually how it's done by JavaScript based DApps but they get the benefit of being abstracted away from the function call encoding process by the web3.js library. I actually had started on similar libraries for Elixir and Ruby which I will pick back up when I have some spare time.

    It would be cool to have a Ruby based interface to Ethereum as this would pave the way for interop with Rails, Sinatra, Volt, other Ruby based web frameworks, or native OS X DApps via RubyMotion.
    Post edited by StephanTual on
  • You can start with ethereum.rb, which is recent ruby gem designed to be easy to use. It comes with step by step usage guide in readme and introduction video to smart contracts.
Sign In or Register to comment.