Class: Arweave::Api

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/arweave/api.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instanceObject



8
9
10
11
12
13
14
15
# File 'lib/arweave/api.rb', line 8

def instance
  @instance ||=
    new(
      scheme: Client.configuration&.scheme || 'https',
      host: Client.configuration&.host || 'arweave.net',
      port: Client.configuration&.port || '443'
    )
end

Instance Method Details

#commit(transaction) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/arweave/api.rb', line 46

def commit(transaction)
  self.class.post(
    '/tx',
    body: transaction.attributes.to_json,
    headers: { 'Content-Type' => 'application/json' }
  )
end

#get_last_transaction_id(wallet_address) ⇒ Object



34
35
36
# File 'lib/arweave/api.rb', line 34

def get_last_transaction_id(wallet_address)
  self.class.get("/wallet/#{wallet_address}/last_tx")
end

#get_transaction(transaction_id) ⇒ Object



22
23
24
# File 'lib/arweave/api.rb', line 22

def get_transaction(transaction_id)
  self.class.get("/tx/#{transaction_id}")
end

#get_transaction_anchorObject



18
19
20
# File 'lib/arweave/api.rb', line 18

def get_transaction_anchor
  self.class.get('/tx_anchor')
end

#get_transaction_data(transaction_id) ⇒ Object



26
27
28
# File 'lib/arweave/api.rb', line 26

def get_transaction_data(transaction_id)
  self.class.get("/tx/#{transaction_id}/data")
end

#get_transaction_status(transaction_id) ⇒ Object



30
31
32
# File 'lib/arweave/api.rb', line 30

def get_transaction_status(transaction_id)
  self.class.get("/tx/#{transaction_id}/status")
end

#get_wallet_balance(wallet_address) ⇒ Object



38
39
40
# File 'lib/arweave/api.rb', line 38

def get_wallet_balance(wallet_address)
  self.class.get("/wallet/#{wallet_address}/balance")
end

#reward(byte_size, address = '') ⇒ Object



42
43
44
# File 'lib/arweave/api.rb', line 42

def reward(byte_size, address = '')
  self.class.get("/price/#{byte_size}/#{address}")
end