Class: SafeEthRuby::Contract

Inherits:
Object
  • Object
show all
Defined in:
lib/safe_eth_ruby/contract.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(safe_address:, rpc:) ⇒ Contract

Returns a new instance of Contract.



9
10
11
12
13
14
15
16
# File 'lib/safe_eth_ruby/contract.rb', line 9

def initialize(safe_address:, rpc:)
  @client = Eth::Client.create(rpc)
  @safe_contract = Eth::Contract.from_abi(
    name: "SafeContract",
    address: safe_address,
    abi: SafeEthRuby::ABI::PROXY,
  )
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/safe_eth_ruby/contract.rb', line 7

def client
  @client
end

#safe_contractObject (readonly)

Returns the value of attribute safe_contract.



7
8
9
# File 'lib/safe_eth_ruby/contract.rb', line 7

def safe_contract
  @safe_contract
end

Instance Method Details

#nonceObject

Fetch nonce from the contract



19
20
21
22
23
# File 'lib/safe_eth_ruby/contract.rb', line 19

def nonce
  @client.call(@safe_contract, "nonce")
rescue StandardError => e
  warn("Error fetching nonce: #{e.message}")
end