Class: Kortana::Modules::Contracts
- Inherits:
-
Object
- Object
- Kortana::Modules::Contracts
- Defined in:
- lib/kortana/modules/contracts.rb
Instance Method Summary collapse
- #deploy_contract(abi:, bytecode:, args: nil) ⇒ Object
- #estimate_contract_gas(address, abi, method, args = [], options = {}) ⇒ Object
- #get_contract_events(address, abi, event_name, filter = {}) ⇒ Object
-
#initialize(client) ⇒ Contracts
constructor
A new instance of Contracts.
- #read_contract(address, abi, method, args = []) ⇒ Object
- #verify_contract(address, source_code:, compiler_version:, optimizer: false, optimizer_runs: 200) ⇒ Object
- #write_contract(address, abi, method, args = [], options = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ Contracts
Returns a new instance of Contracts.
4 5 6 |
# File 'lib/kortana/modules/contracts.rb', line 4 def initialize(client) @client = client end |
Instance Method Details
#deploy_contract(abi:, bytecode:, args: nil) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/kortana/modules/contracts.rb', line 8 def deploy_contract(abi:, bytecode:, args: nil) @client.post("/contracts/deploy", { abi: abi, bytecode: bytecode, args: args }) end |
#estimate_contract_gas(address, abi, method, args = [], options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/kortana/modules/contracts.rb', line 34 def estimate_contract_gas(address, abi, method, args = [], = {}) res = @client.post("/contracts/#{address}/estimate-gas", { abi: abi, method: method, args: args, options: }) res["gasLimit"].to_i end |
#get_contract_events(address, abi, event_name, filter = {}) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/kortana/modules/contracts.rb', line 44 def get_contract_events(address, abi, event_name, filter = {}) @client.post("/contracts/#{address}/events", { abi: abi, eventName: event_name, filter: filter }) end |
#read_contract(address, abi, method, args = []) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/kortana/modules/contracts.rb', line 16 def read_contract(address, abi, method, args = []) res = @client.post("/contracts/#{address}/read", { abi: abi, method: method, args: args }) res["result"] end |
#verify_contract(address, source_code:, compiler_version:, optimizer: false, optimizer_runs: 200) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/kortana/modules/contracts.rb', line 52 def verify_contract(address, source_code:, compiler_version:, optimizer: false, optimizer_runs: 200) @client.post("/contracts/#{address}/verify", { sourceCode: source_code, compilerVersion: compiler_version, optimizer: optimizer, optimizerRuns: optimizer_runs }) end |
#write_contract(address, abi, method, args = [], options = {}) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/kortana/modules/contracts.rb', line 25 def write_contract(address, abi, method, args = [], = {}) @client.post("/contracts/#{address}/write", { abi: abi, method: method, args: args, options: }) end |