Package: dfktools
Install withpip install dfktoolshttps://pypi.org/project/dfktools/DefiKingdoms toolboxThis is a simple toolbox to interact with the contracts ofDefiKingdomsThis software is not endorsed by, directly affiliated with, maintained, authorized, or sponsored by the DefiKingdoms team.
All product and company names are the registered trademarks of their original owners.
The use of any trade name or trademark is for identification and reference purposes only and does not imply any association with the trademark holder of their product brand.Like this project ? Consider supporting future developments by:Delegating AVAX to our Avalanche nodeNodeID-4btZGj8TmrycK22kwgBK5wJEFighAFWiZMaking a donation to0xA68fBfa3E0c86D1f3fF071853df6DAe8753095E2Need help ? Join theGameFi Developers DiscordCode guidelinesIndent with Tab1 empty line within a function, 2 empty lines between functionUsetrait(s)to name any or all of the 8 valuestrength, agility, intelligence, wisdom, luck, vitality, endurance, dexterityUseability(ies)to name any or all of the 4 valuepassive1, passive2, active1, active2Usestat(s)as a generic term for any or all the characteristics of a hero (traits, abilities, HP, MP, stamina, etc)A function should support all realms, except if contracts differs across realmsAll hardcoded addresses should beCheckSummedUselogging, notprintNo other third-party libraries (if really needed, please explain why in the PR)A short & meaningful comment is better than a long & unfathomable documentationHero contractThe hero contract is accessible withhero/hero.pyQuickstarthero_example.pyTransferTransfer a hero from one address to anotherInfoHero's data can be retrieved with theget_heromethod. A morehuman-friendlyformat can be generated
by passing the result ofget_heroto thehuman_readable_heromethod.OwnerThe owner of a hero can be retrieved with the methodget_ownerProfile contractThe profile contract is accessible withprofile/profile_v2.pyQuickstartprofile_example.pyIn-game profileIn-game profile can be retrieved with theget_profilemethodSummoning contractThe summoning contract is accessible withsummoning/summoning.pyQuickstartsummoning_example.pyCreate crystalSummoning crystal are created withsummon_crystalmethodCrystal idCrystal id can be retrieved withget_user_crystal_idsmethodOpen summoning crystalSummoning crystal can be open withopen_crystalmethodRent auctionPut a hero up for hire withput_hero_for_rentand cancel withcancel_rentUseis_on_rentandget_rent_auctionto monitor auctionGene science contractThe gene science contract is accessible withgenes/gene_science_v2.pyQuickstartgenes_example.pyMix genesStatistics and visual of summoned hero can be forecasted with themix_genesmethod.
Note thatmix_genesis pseudo random and the resulting traits will be different for each block.
However, a statistical analysis can be used to optimize the summoning of desirable traitsAuction contractThe hero sale auction contract is accessible withauctions/hero/sale_auctions.pyThe hero rent auction contract is accessible withauctions/hero/rent_auctions.pyGeneric sale auction (ex: land) contract are accessible withauctions/auction.pyQuickstartauction_example.pyland_example.pySale auctionbid_heroandget_auctioninteract directly with the contract.get_recent_open_auctionsandget_hero_open_auctionsuse Graphql.Rent auctionget_recent_open_auctionsandget_hero_open_auctionsuse Graphql.QuestAll quest contracts are located in modulequestsQuickstartquest_example.pyForaging & Fishing questEach quest requires at least 7 stamina to complete. Check the current stamina of any given hero withget_current_stamina.
Start the quest withstart_quest. The second parameter is the number of attempt. To optimize the cost of gas, it is recommended
to use a hero at full stamina and do 3 attempts every call.Uses V2 questGardening & Mining questGardening and mining quest can be started with just one stamina.
Mining quest can be done with up to 6 heroes while only 1 hero at a time can be sent on a gardening quest to a specific garden (liquidity pool).Uses V1 questLegacy wishing well questwishing_well_quest_example.pyDEX & tokensIn game tokens and AMM exchange are available in moduledexQuickstartdex_example.pyBalance of tokenUsedex.erc20.balance_ofto retrieve the balance of an item for the specified addressLiquidity poolUse wrapper classdex.uniswap_v2_pair.UniswapV2Pairand callexpected_amount0to get the estimated amount oftoken0received in exchange oftoken1.
Alternatively, calldex.uniswap_v2_router.quoteSwap tokenUse calldex.uniswap_v2_router.swap_exact_tokens_for_ethto swap erc20 token for ONE.
Use calldex.uniswap_v2_router.swap_exact_tokens_for_tokensto swap erc20 tokens for other erc20 tokens.Staking poolUse wrapper classdex.master_gardener.Gardento retrieve staking pool infoMeditation circleMeditation circle contract is accessible withmeditation/meditation.pyQuickstartmeditation_example.pyHero level upUsestart_meditationandcomplete_meditationto level up a hero. Make sure to have enough rune for the hero's level withget_required_runesDuelAll duel contracts are located in moduleduelQuickstartduel_example.pyRaffle masterAll raffle contracts are located in moduleraffleQuickstartraffle_example.pyPetsAll pet related contracts are located in modulepetsUsepet.pyto manage pet NFTUsehatchery.pyto hatch pet eggUseexchange.pyto exchange 2 pets for an eggQuickstartpet_example.pyBridgeAll bridge contracts are located in modulebridgeBe careful to not mix up RPCs when dealing with multichain transactionQuickstartbridge_example.py