0rtis / dfktools Goto Github PK
View Code? Open in Web Editor NEWInteract with the contracts of DefiKingdoms
License: MIT License
Interact with the contracts of DefiKingdoms
License: MIT License
Hi, in the spirit of DFK Heroes Price Prediction, I would like to retrieve the last N purchases of heroes together with their paid price. From them, I already know how to query for IDs and get all the hero stats ("hero_example.py"), but I do not know how to do the first step.
Is this possible with "dfktools"?
Many thanks
level = 1
questV2.start_quest(quest_contract, my_heroes_id, attempts, level, private_key, w3.eth.getTransactionCount(account_address), gas_price_gwei, tx_timeout)
What is the level? Tried it with the current level of the hero, but this didn't work and currently I don't know what I need to enter there.
Error Message is always: "Error execution reverted: level not found"
When attempting to send heroes on the gold mining quest with the following code:
questV2.start_quest(quest_contract, group, attempts, level, private_key, w3.eth.getTransactionCount(account_address), gas_price_gwei, tx_timeout)
The following error occurs:
execution reverted: quest not active
Hi,
any plans to add a single quest support (for example gardening, probably mining, etc)?
Thanks for this nice repo
There is no info on how to start v1 quests for crystalvale like mining, also it seems that quest_core_v1 needs to be updated as to reflect the changes. If anyone can help us please let us know in a comment
Can someone write a quick example for how to query the current price of a token pair? I fail to understand the get_amount_in
function in dex/uniswap_v2_router.py
or how to pass what tokens I want or what the reserve values are supposed to be. I've read the uniswap docs and its still a complete mystery to me
I was using wishing well tool for exping heroes. After few days I've noticed that tears gain drastically dropped. Many complete quest transactions were revered. Every revered quest had mined gaia's tears in internal transaction log. Another attempt to finish this quest was succeed but without additional xp/tears.
reverted tears.txt
succeed quests.txt
I figured out that reason of reverting quests with mined tears was lack of maxGasUsed variable in buildTransaction:
tx = contract.functions.completeQuest(hero_id).buildTransaction(
{'gasPrice': w3.toWei(gas_price_gwei, 'gwei'), 'nonce': `nonce})
after adding maxGasUsed heroes normally started to earn bonus XP and tears
tx = contract.functions.completeQuest(hero_id).buildTransaction(
{'gasPrice': w3.toWei(gas_price_gwei, 'gwei'), 'nonce': nonce, 'gas': 600000})
Another issue is that auction tool stopped working since they changed graphql query. Unfortunately I have no skills to fix this
Attempting to use CV's JEWEL address in any functions that uses "token_address" as the variable causes the error "InsufficientDataBytes: Tried to read 32 bytes. Only got 0 bytes".
`import dfktools.dex.erc20 as tokens
import logging
import sys
from web3 import Web3
log_format = '%(asctime)s|%(name)s|%(levelname)s: %(message)s'
logger = logging.getLogger("DFK-erc20")
logger.setLevel(logging.DEBUG)
logging.basicConfig(level=logging.INFO, format=log_format, stream=sys.stdout)
rpc_server = 'https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc'
logger.info("Using RPC server " + rpc_server)
w3 = Web3(Web3.HTTPProvider(rpc_server))
realm = 'crystalvale'
crystalvale_items = tokens.get_realm_item_list(realm)
logger.info('{} items in {}'.format(len(serendale_items), realm))
token_address = tokens.symbol2address('JEWEL', realm)
name = tokens.name(token_address, rpc_server)
`
^Errors out at "tokens.name(token_address, rpc_server)" or any other functions that uses CV JEWEL's token address. Functions work for other token addresses that is not CV JEWEL. i.e. CV Crystal address works fine.
Any ideas?
Is there a way to search thru the entire hero catalog?
This isn't an issue with this code but rather the graphql query. When I use saleAuctions the most recent data is a few days old. Am I doing something wrong?
I'm using get_open_auctions as is.
Is there an API to query the tavern, with the ability to set filters?
I guess I'm doing something wrong, but I tried the quest_example.py and changed the PrivateKey and heros_id
Error I receive:
2022-02-10 09:00:38,248|DFK-quest|INFO: Waiting for transaction https://explorer.harmony.one/tx/ to be mined
Traceback (most recent call last):
File "/home/environments/dfk/lib/python3.8/site-packages/web3/eth.py", line 740, in wait_for_transaction_receipt
_timeout.sleep(poll_latency)
File "/home/environments/dfk/lib/python3.8/site-packages/web3/_utils/threads.py", line 89, in sleep
self.check()
File "/home/environments/dfk/lib/python3.8/site-packages/web3/_utils/threads.py", line 82, in check
raise self
web3._utils.threads.Timeout: 30 seconds
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 35, in
quest.start_quest(quest_contract, my_heroes_id, 3, private_key, w3.eth.getTransactionCount(account_address), gas_price_gwei, tx_timeout)
File "/home/environments/dfk/code/quest/quest.py", line 10, in start_quest
return quest_core.start_quest(quest_address, hero_ids, attempts, private_key, nonce, gas_price_gwei, tx_timeout_seconds, self.rpc_address, self.logger)
File "/home/environments/dfk/code/quest/quest_core.py", line 86, in start_quest
tx_receipt = w3.eth.wait_for_transaction_receipt(transaction_hash=signed_tx.hash, timeout=tx_timeout_seconds,
File "/home/environments/dfk/lib/python3.8/site-packages/web3/eth.py", line 744, in wait_for_transaction_receipt
raise TimeExhausted(
web3.exceptions.TimeExhausted: Transaction HexBytes('') is not in the chain after 30 seconds
If I go to the explorer link, I also don't see the transaction.
I guess I'm missing something?
it should be: DFKTEAR = "0x24eA0D436d3c2602fbfEfBe6a16bBc304C963D04" in items
startQuest() does not work for me on the new contract
Start Quest (Uint256[], Address, Uint8, Uint8)
seems like a 4th input is needed. just in case it helps:
hex:'0x8a2da17b0000000000000000000000000000000000000000000000000000000000000080
000000000000000000000000b465f4590095dad50fee6ee0b7c6700ac2b04df8 <- new fishing/foraging address
0000000000000000000000000000000000000000000000000000000000000001 <- number of quests
0000000000000000000000000000000000000000000000000000000000000000 <- (quest level?)
0000000000000000000000000000000000000000000000000000000000000002 <- number of heroes
00000000000000000000000000000000000000000000000000000000HERO_ID1
00000000000000000000000000000000000000000000000000000000HERO_ID2'
I am trying to read data for hero #58642
when I try to get his current stamina i get error
Traceback (most recent call last):
File "c:_code\Python\dfk_multi_questing\src\dfktools\src\dfktools\quest_example.py", line 68, in
hero_stam = questV2.get_current_stamina(hero_id)
File "c:_code\Python\dfk_multi_questing\src\dfktools\src\dfktools\quests\quest_v2.py", line 42, in get_current_stamina
return quest_core_v2.get_current_stamina(self.quest_core_contract_address, hero_id, self.rpc_address)
File "c:_code\Python\dfk_multi_questing\src\dfktools\src\dfktools\quests\quest_core_v2.py", line 320, in get_current_stamina
result = contract.functions.getCurrentStamina(hero_id).call()
File "C:\Python\lib\site-packages\web3\contract.py", line 957, in call
return call_contract_function(
File "C:\Python\lib\site-packages\web3\contract.py", line 1501, in call_contract_function
return_data = web3.eth.call(
File "C:\Python\lib\site-packages\web3\module.py", line 57, in caller
result = w3.manager.request_blocking(method_str,
File "C:\Python\lib\site-packages\web3\manager.py", line 198, in request_blocking
return self.formatted_response(response,
File "C:\Python\lib\site-packages\web3\manager.py", line 170, in formatted_response
apply_error_formatters(error_formatters, response)
File "C:\Python\lib\site-packages\web3\manager.py", line 70, in apply_error_formatters
formatted_resp = pipe(response, error_formatters)
File "cytoolz\functoolz.pyx", line 667, in cytoolz.functoolz.pipe
File "cytoolz\functoolz.pyx", line 642, in cytoolz.functoolz.c_pipe
File "C:\Python\lib\site-packages\web3_utils\method_formatters.py", line 576, in raise_solidity_error_on_revert
raise ContractLogicError(response['error']['message'])
web3.exceptions.ContractLogicError: execution reverted
this is both on DFK and Klaytn
when I try to read owner of this hero i get error
Traceback (most recent call last):
File "c:_code\Python\dfk_multi_questing\src\dfktools\src\dfktools\hero_example.py", line 57, in
owner = crystalvale_heroes.get_owner(cv_hero_id)
File "c:_code\Python\dfk_multi_questing\src\dfktools\src\dfktools\hero\hero.py", line 14, in get_owner
return hero_core.get_owner(self.contract_address, hero_id, self.rpc_address, block_identifier)
File "c:_code\Python\dfk_multi_questing\src\dfktools\src\dfktools\hero\hero_core.py", line 124, in get_owner
return str(contract.functions.ownerOf(hero_id).call(block_identifier=block_identifier))
File "C:\Python\lib\site-packages\web3\contract.py", line 957, in call
return call_contract_function(
File "C:\Python\lib\site-packages\web3\contract.py", line 1501, in call_contract_function
return_data = web3.eth.call(
File "C:\Python\lib\site-packages\web3\module.py", line 57, in caller
result = w3.manager.request_blocking(method_str,
File "C:\Python\lib\site-packages\web3\manager.py", line 198, in request_blocking
return self.formatted_response(response,
File "C:\Python\lib\site-packages\web3\manager.py", line 170, in formatted_response
apply_error_formatters(error_formatters, response)
File "C:\Python\lib\site-packages\web3\manager.py", line 70, in apply_error_formatters
formatted_resp = pipe(response, error_formatters)
File "cytoolz\functoolz.pyx", line 667, in cytoolz.functoolz.pipe
File "cytoolz\functoolz.pyx", line 642, in cytoolz.functoolz.c_pipe
File "C:\Python\lib\site-packages\web3_utils\method_formatters.py", line 576, in raise_solidity_error_on_revert
raise ContractLogicError(response['error']['message'])
web3.exceptions.ContractLogicError: execution reverted: ERC721: owner query for nonexistent token
when i try to read hero data I get a result but all attributes are 0
{'id': 58642, 'summoningInfo': {'summonedTime': 0, 'nextSummonTime': 0, 'summonerId': 0, 'assistantId': 0, 'summons': 0, 'maxSummons': 0}, 'info': {'statGenes': 0, 'visualGenes': 0, 'rarity': 0, 'shiny': False, 'generation': 0, 'firstName': 0, 'lastName': 0, 'shinyStyle': 0, 'class': 0, 'subClass': 0}, 'state': {'staminaFullAt': 0, 'hpFullAt': 0, 'mpFullAt': 0, 'level': 0, 'xp': 0, 'currentQuest': '0x0000000000000000000000000000000000000000', 'sp': 0, 'status': 0}, 'stats': {'strength': 0, 'intelligence': 0, 'wisdom': 0, 'luck': 0, 'agility': 0, 'vitality': 0, 'endurance': 0, 'dexterity': 0, 'hp': 0, 'mp': 0, 'stamina': 0}, 'primaryStatGrowth': {'strength': 0, 'intelligence': 0, 'wisdom': 0, 'luck': 0, 'agility': 0, 'vitality': 0, 'endurance': 0, 'dexterity': 0, 'hpSm': 0, 'hpRg': 0, 'hpLg': 0, 'mpSm': 0, 'mpRg': 0, 'mpLg': 0}, 'secondaryStatGrowth': {'strength': 0, 'intelligence': 0, 'wisdom': 0, 'luck': 0, 'agility': 0, 'vitality': 0, 'endurance': 0, 'dexterity': 0, 'hpSm': 0, 'hpRg': 0, 'hpLg': 0, 'mpSm': 0, 'mpRg': 0, 'mpLg': 0}, 'professions': {'mining': 0, 'gardening': 0, 'foraging': 0, 'fishing': 0}}
hero works normally in the games official interface and shows all data in dfk tools so it must be accessible through the rpc calls
all code works fine with all other hero IDs i tried
I sent hero to different account and bridged from klaytn to serendale, it still behaves the same
Hello.
I'm not a professional python programmer but i've made profession questing (based on your wishing_well.py). It works fine but it may containes some newbie bugs. I hope it will be useful for ur project.
https://pastebin.com/xVNqQwwr
Line 74 and 75 the dict keys for quest V2 are different.
item = rew['args']['rewardItem'] # V2 = rew['args']['reward']
qty = rew['args']['itemQuantity'] # V2 = rew['args']['amount']
Everything else is the same
Have you considered build this package and upload to pip so it's easier to use as a lib? Thanks.
I think all that's needed is to parse the RewardMinted event instead of QuestReward.
is this still maintained? looking forward to automate some pet feeding process
https://devs.defikingdoms.com/nfts/pets
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.