Class: Sigma::Contract
- Inherits:
-
Object
- Object
- Sigma::Contract
- Extended by:
- FFI::Library
- Defined in:
- lib/sigma/contract.rb
Overview
Defines the contract (script) that will be guarding box contents
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Class Method Summary collapse
-
.compile_from_string(source) ⇒ Contract
Compiles a contract from ErgoScript source code.
-
.from_ergo_tree(ergo_tree) ⇒ Contract
Create a new contract from an ErgoTree.
-
.pay_to_address(address) ⇒ Contract
Create new contract that allow spending of the guarded box by a given recipient (Address).
-
.with_raw_pointer(contract_pointer) ⇒ Contract
Takes ownership of an existing Contract Pointer.
Instance Method Summary collapse
-
#==(contract_two) ⇒ bool
Equality check for two Contracts.
-
#get_ergo_tree ⇒ ErgoTree
Get the ErgoTree of the contract.
Instance Attribute Details
#pointer ⇒ Object
Returns the value of attribute pointer.
18 19 20 |
# File 'lib/sigma/contract.rb', line 18 def pointer @pointer end |
Class Method Details
.compile_from_string(source) ⇒ Contract
Compiles a contract from ErgoScript source code
41 42 43 44 45 46 47 |
# File 'lib/sigma/contract.rb', line 41 def self.compile_from_string(source) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_contract_compile(source, pointer) Util.check_error!(error) init(pointer) end |
.from_ergo_tree(ergo_tree) ⇒ Contract
Create a new contract from an ErgoTree
31 32 33 34 35 36 |
# File 'lib/sigma/contract.rb', line 31 def self.from_ergo_tree(ergo_tree) pointer = FFI::MemoryPointer.new(:pointer) ergo_lib_contract_new(ergo_tree.pointer, pointer) init(pointer) end |
.pay_to_address(address) ⇒ Contract
Create new contract that allow spending of the guarded box by a given recipient (Address)
52 53 54 55 56 57 58 |
# File 'lib/sigma/contract.rb', line 52 def self.pay_to_address(address) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_contract_pay_to_address(address.pointer, pointer) Util.check_error!(error) init(pointer) end |
.with_raw_pointer(contract_pointer) ⇒ Contract
A user of sigma_rb generally does not need to call this function
Takes ownership of an existing Contract Pointer.
24 25 26 |
# File 'lib/sigma/contract.rb', line 24 def self.with_raw_pointer(contract_pointer) init(contract_pointer) end |
Instance Method Details
#==(contract_two) ⇒ bool
Equality check for two Contracts
71 72 73 |
# File 'lib/sigma/contract.rb', line 71 def ==(contract_two) ergo_lib_contract_eq(self.pointer, contract_two.pointer) end |
#get_ergo_tree ⇒ ErgoTree
Get the ErgoTree of the contract
62 63 64 65 66 |
# File 'lib/sigma/contract.rb', line 62 def get_ergo_tree pointer = FFI::MemoryPointer.new(:pointer) ergo_lib_contract_ergo_tree(self.pointer, pointer) Sigma::ErgoTree.with_raw_pointer(pointer) end |