3

At this time I'm just trying to setup the simplest of apps where I click a button and that will send the most basic of transactions to my testrpc network. It's easy to do with JS and web3, but how can I do this with Ruby on Rails ?

1

2 Answers 2

1

There are many ways to connect Rails with Ethereum,

I recently used

  • coinfalcon for Python and Ruby. This provides API for placing orders with the help of this.
  • Ethereum Ruby This helps you connect with Ethereum.

Here you can do:

  1. IPC Client Connection
  2. Solidity contract compilation and deployment
  3. Transacting and Calling Solidity Functions
1

I have published an Ethereum on Rails template.

It is a boilerplate application that allows authenticating users in your Rails 7.0 application with an Ethereum wallet (e.g., MetaMask).

You can use this repository as a template to create your custom Rails application that already has Ethereum support bundled. For example, it uses the new eth gem for Ethereum account management.

If you already know how to use Rails, you can utilize the following functionality of the eth gem:

test_rpc = Eth::Client.create "http://127.0.0.1:8545"
some_trx = Eth::Tx.new {
  chain_id: test_rpc.chain_id,
  nonce: test_rpc.get_nonce test_rpc.default_account,
  priority_fee: 1 * Eth::Unit::GWEI,
  max_gas_fee: 23 * Eth::Unit::GWEI,
  gas_limit: Eth::Tx.estimate_intrinsic_gas,
  to: Eth::Address.new "0xCaA29806044A08E533963b2e573C1230A2cd9a2d",
  value: 1 * Eth::Unit::ETHER,
}

And then you can sign and broadcast it, see: https://github.com/q9f/eth.rb/wiki/Transactions

Or simply run:

test_rpc.transfer Eth::Address.new("0xCaA29806044A08E533963b2e573C1230A2cd9a2d"), 1 * Eth::Unit::ETHER

See https://github.com/q9f/eth.rb/wiki/RPC-Client

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.