0.0
The project is in a healthy, maintained state
The Safe gem simplifies Gnosis Safe integration in Ruby apps, managing multisig transactions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 13.0

Runtime

~> 0.2.8
~> 0.5.11
 Project Readme

SafeEthRubyGem

Welcome to SafeEthRubyGem! This gem provides functionality to interact with Ethereum smart contracts safely using Ruby.

Installation

To install the gem, add it to your Gemfile:

$ bundle add safe_eth_ruby

Usage

require "safe_eth_ruby"

owner = Eth::Key.new(priv: ENV["OWNER_SAFE"])
delegate = Eth::Key.new(priv: ENV["DELEGATE_KEY"])
rpc = "https://eth-sepolia.g.alchemy.com/v2/#{ENV["ALCHEMY_KEY"]}"

api = SafeEthRuby::TransactionServiceApi.new(chain_id: 11155111, safe_address: ENV["SAFE_ADDRESS"])

transactions = [
  { operation: 0, to: "0x", value: 1, data: Eth::Util.hex_to_bin("0x") },
  { operation: 0, to: "0x", value: 1, data: Eth::Util.hex_to_bin("0x") },
]

1. if the signer's address is a delegate

api.delegates
response = api.delete_delegate(delegate_address: delegate.address.to_s, owner:)

response = api.add_delegate(label: "Signer Delegate", delegate_address: delegate.address.to_s, owner:)

2. createTransaction

protocol = SafeEthRuby::Protocol.new(signer: delegate, chain_id: 11155111, safe_address: ENV["SAFE_ADDRESS"], rpc:)

response = protocol.create_transaction(transactions)

Development

  1. Clone the repository.
  2. Run bin/setup to install dependencies.
  3. Run rake test to run the tests.
  4. Use bin/console for an interactive prompt to experiment.

To install this gem onto your local machine, run bundle exec rake install.

To release a new version:

  1. Update the version number in version.rb.
  2. Run bundle exec rake release.
  3. This will create a git tag for the version, push git commits and the created tag, and push the .gem file to RubyGems.

Contributing

Bug reports and pull requests are welcome on GitHub.