class Laksa::Contract::ContractFactory
individual `Contract` instances are instead obtained by calling `ContractFactory.at` (for an already-deployed contract) and `ContractFactory.new` (to deploy a new contract).
Attributes
provider[R]
signer[R]
Public Class Methods
get_address_for_contract(tx)
click to toggle source
# File lib/laksa/contract/contract_factory.rb, line 19 def self.get_address_for_contract(tx) sha256 = Digest::SHA256.new sender_address = Laksa::Crypto::KeyTool.get_address_from_public_key(tx.sender_pub_key) sha256 << Util.decode_hex(sender_address) nonce = 0; if tx.nonce && !tx.nonce.empty? nonce = tx.nonce.to_i - 1 end nonce_hex = [nonce].pack('Q>*') sha256 << nonce_hex sha256.hexdigest[24..-1] end
new(provider, signer)
click to toggle source
# File lib/laksa/contract/contract_factory.rb, line 14 def initialize(provider, signer) @provider = provider @signer = signer end
Public Instance Methods
at_contract(address, code, init, abi)
click to toggle source
# File lib/laksa/contract/contract_factory.rb, line 42 def at_contract(address, code, init, abi) Contract.new(self, code, abi, address, init, nil) end
new_contract(code, init, abi)
click to toggle source
# File lib/laksa/contract/contract_factory.rb, line 38 def new_contract(code, init, abi) Contract.new(self, code, abi, nil, init, nil) end