Hello everyone,
I've been working since this morning on a way to execute a smart
contract from a Ruby on Rails application. First, I was doing it
manually trough the JSON-RPC API, and it was not easy to do. After a
while, I started to work on a better way to work with smart-contracts
through ruby. After all, Ruby is a very efficient language when it comes
to create an API, with all the meta-programming stuff. I wanted to make
something as easy as ActiveRecord can be when it comes to describe
databases relations.
After a first draft, I ended up wanting something like that :
class Citizen < Etheruby::Contract
# Contract address on the blockchain
at_address 0x57eb1e64d972d9937c6f6f07a865e91608252c97
# ABI Definition
method :greet
method :multiple do
parameters :int256, :int256
returns :int256
value 1
gas 100
gas_price 10000
end
end
That could be called with :
Citizen.greet
result = Citizen.multiple(4,5)
And for now, I'm able to get this :
irb(main):001:0> Citizen.greet
Data to send : 0xcfae3217
irb(main):001:0> Citizen.multiple(4,5)
Data to send :
0xb0008fa200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000005
Which is not a big thing, but it is a start point !
I've just pushed on github the begining of my work :
If some ethereum-enthusiast rubyists want to contribute to this project,
you're welcome, there is still a lot of work to do !