A toolbox for DefiKingdoms
Project description
Install with pip install dfktools
https://pypi.org/project/dfktools/
DefiKingdoms toolbox
This is a simple toolbox to interact with the contracts of DefiKingdoms
This 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 node NodeID-4btZGj8TmrycK22kwgBK5wJEFighAFWiZ
- Making a donation to 0xA68fBfa3E0c86D1f3fF071853df6DAe8753095E2
Need help ? Join the GameFi Developers Discord
Code guidelines
- Indent with Tab
- 1 empty line within a function, 2 empty lines between function
- Use trait(s) to name any or all of the 8 value
strength, agility, intelligence, wisdom, luck, vitality, endurance, dexterity
- Use ability(ies) to name any or all of the 4 value
passive1, passive2, active1, active2
- Use stat(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 realms
- All hardcoded addresses should be CheckSummed
- Use
logging
, notprint
- No other third-party libraries (if really needed, please explain why in the PR)
- A short & meaningful comment is better than a long & unfathomable documentation
Hero contract
The hero contract is accessible with hero/hero.py
Quickstart
Transfer
Transfer a hero from one address to another
Info
Hero's data can be retrieved with the get_hero
method. A more human-friendly format can be generated
by passing the result of get_hero
to the human_readable_hero
method.
Owner
The owner of a hero can be retrieved with the method get_owner
Profile contract
The profile contract is accessible with profile/profile_v2.py
Quickstart
In-game profile
In-game profile can be retrieved with the get_profile
method
Summoning contract
The summoning contract is accessible with summoning/summoning.py
Quickstart
Create crystal
Summoning crystal are created with summon_crystal
method
Crystal id
Crystal id can be retrieved with get_user_crystal_ids
method
Open summoning crystal
Summoning crystal can be open with open_crystal
method
Rent auction
Put a hero up for hire with put_hero_for_rent
and cancel with cancel_rent
Use is_on_rent
and get_rent_auction
to monitor auction
Gene science contract
The gene science contract is accessible with genes/gene_science_v2.py
Quickstart
Mix genes
Statistics and visual of summoned hero can be forecasted with the mix_genes
method.
Note that mix_genes
is 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 traits
Auction contract
The hero sale auction contract is accessible with auctions/hero/sale_auctions.py The hero rent auction contract is accessible with auctions/hero/rent_auctions.py Generic sale auction (ex: land) contract are accessible with auctions/auction.py
Quickstart
auction_example.py land_example.py
Sale auction
bid_hero
and get_auction
interact directly with the contract.
get_recent_open_auctions
and get_hero_open_auctions
use Graphql.
Rent auction
get_recent_open_auctions
and get_hero_open_auctions
use Graphql.
Quest
All quest contracts are located in module quests
Quickstart
Foraging & Fishing quest
Each quest requires at least 7 stamina to complete. Check the current stamina of any given hero with get_current_stamina
.
Start the quest with start_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 quest
Gardening & Mining quest
Gardening 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 quest
Legacy wishing well quest
DEX & tokens
In game tokens and AMM exchange are available in module dex
Quickstart
Balance of token
Use dex.erc20.balance_of
to retrieve the balance of an item for the specified address
Liquidity pool
Use wrapper class dex.uniswap_v2_pair.UniswapV2Pair
and call expected_amount0
to get the estimated amount of token0
received in exchange of token1
.
Alternatively, call dex.uniswap_v2_router.quote
Swap token
Use call dex.uniswap_v2_router.swap_exact_tokens_for_eth
to swap erc20 token for ONE.
Use call dex.uniswap_v2_router.swap_exact_tokens_for_tokens
to swap erc20 tokens for other erc20 tokens.
Staking pool
Use wrapper class dex.master_gardener.Garden
to retrieve staking pool info
Meditation circle
Meditation circle contract is accessible with meditation/meditation.py
Quickstart
Hero level up
Use start_meditation
and complete_meditation
to level up a hero. Make sure to have enough rune for the hero's level with get_required_runes
Duel
All duel contracts are located in module duel
Quickstart
Raffle master
All raffle contracts are located in module raffle
Quickstart
Pets
All pet related contracts are located in module pets
Use pet.py to manage pet NFT
Use hatchery.py to hatch pet egg
Use exchange.py to exchange 2 pets for an egg
Quickstart
Bridge
All bridge contracts are located in module bridge
Be careful to not mix up RPCs when dealing with multichain transaction
Quickstart
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dfktools-0.3.2.tar.gz
.
File metadata
- Download URL: dfktools-0.3.2.tar.gz
- Upload date:
- Size: 104.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90f5571e3d1634dcf4ef88807b004c59e02d606777563166beca31712a37922e |
|
MD5 | 58e50f0d11eaeccf7d60efc6676f236a |
|
BLAKE2b-256 | 9b1a26a1bcbbd1f74d31609bfb5e1d85c339f7a0f6e9d2d423cb88c5d0d684b2 |
File details
Details for the file dfktools-0.3.2-py3-none-any.whl
.
File metadata
- Download URL: dfktools-0.3.2-py3-none-any.whl
- Upload date:
- Size: 146.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb098cbcd9bb0497ba5971fa98b6717b53d1d2fc119caf4dbd84d6edad96aa5c |
|
MD5 | d34af42f5ed2d5b4dfca3bb1301f5608 |
|
BLAKE2b-256 | 0084cdd62b7b0a90cecf82b78b7c8963e6fb01dc994aa32081ea5a69fca91986 |