Class: PangolinContractHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/testnets/pangolin_contract_helper.rb

Instance Method Summary collapse

Constructor Details

#initializePangolinContractHelper

Returns a new instance of PangolinContractHelper.



2
3
4
# File 'lib/testnets/pangolin_contract_helper.rb', line 2

def initialize()
  @client = Ethereum::HttpClient.new("https://pangolin-rpc.darwinia.network")
end

Instance Method Details

#get_name_and_symbol(address) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/testnets/pangolin_contract_helper.rb', line 6

def get_name_and_symbol(address)
  contract = Ethereum::Contract.create(name: "Contract", address: address, abi: Tracker.get_erc721_abi, client: @client)
  # Why set a sender?
  # Because the Darwinia Pangolin Network checks the gas fee when it receives a message call.
  # So, it need a `from` address with some tokens
  # Is this a bug?
  contract.sender = "0xC5c1C9c3cEA2f4A68E540b18e63310310FD8af57"
  [contract.call.name(), contract.call.symbol]
end

#get_token_uri(address, token_id) ⇒ Object



16
17
18
19
20
# File 'lib/testnets/pangolin_contract_helper.rb', line 16

def get_token_uri(address, token_id)
  contract = Ethereum::Contract.create(name: "Contract", address: address, abi: Tracker.get_erc721_abi, client: @client)
  contract.sender = "0xC5c1C9c3cEA2f4A68E540b18e63310310FD8af57"
  contract.call.token_uri(token_id)
end

#get_uri(address, token_id) ⇒ Object



22
23
24
25
26
# File 'lib/testnets/pangolin_contract_helper.rb', line 22

def get_uri(address, token_id)
  contract = Ethereum::Contract.create(name: "Contract", address: address, abi: Tracker.get_erc1155_abi, client: @client)
  contract.sender = "0xC5c1C9c3cEA2f4A68E540b18e63310310FD8af57"
  contract.call.uri(token_id)
end