Class: Zilliqa::Contract::ContractFactory
- Inherits:
-
Object
- Object
- Zilliqa::Contract::ContractFactory
- Defined in:
- lib/zilliqa/contract/contract_factory.rb
Overview
ContractFactory
individual ‘Contract` instances are instead obtained by calling `ContractFactory.at` (for an already-deployed contract) and `ContractFactory.new` (to deploy a new contract).
Instance Attribute Summary collapse
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#signer ⇒ Object
readonly
Returns the value of attribute signer.
Class Method Summary collapse
Instance Method Summary collapse
- #at_contract(address, code, init, abi) ⇒ Object
-
#initialize(provider, signer) ⇒ ContractFactory
constructor
A new instance of ContractFactory.
- #new_contract(code, init, abi) ⇒ Object
Constructor Details
#initialize(provider, signer) ⇒ ContractFactory
Returns a new instance of ContractFactory.
14 15 16 17 |
# File 'lib/zilliqa/contract/contract_factory.rb', line 14 def initialize(provider, signer) @provider = provider @signer = signer end |
Instance Attribute Details
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
12 13 14 |
# File 'lib/zilliqa/contract/contract_factory.rb', line 12 def provider @provider end |
#signer ⇒ Object (readonly)
Returns the value of attribute signer.
12 13 14 |
# File 'lib/zilliqa/contract/contract_factory.rb', line 12 def signer @signer end |
Class Method Details
.get_address_for_contract(tx) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/zilliqa/contract/contract_factory.rb', line 19 def self.get_address_for_contract(tx) sha256 = Digest::SHA256.new sender_address = Zilliqa::Crypto::KeyTool.get_address_from_public_key(tx.sender_pub_key) sha256 << Util.decode_hex(sender_address) nonce = 0 if tx.nonce nonce = tx.nonce.to_i - 1 end nonce_hex = [nonce].pack('Q>*') sha256 << nonce_hex sha256.hexdigest[24..-1] end |