dfktools


Namedfktools JSON
Version 0.3.1 PyPI version JSON
download
home_pagehttps://github.com/0rtis/dfktools
SummaryA toolbox for DefiKingdoms
upload_time2023-05-29 11:41:19
maintainer
docs_urlNone
authorOrtis
requires_python>=3.8
licenseMIT License Copyright (c) 2022 Ortis (ortis@ortis.io) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords blockchain web3 nft etherum game
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
[![Pypi_repo](https://img.shields.io/pypi/v/dfktools?style=flat-square)](https://pypi.org/project/dfktools/)
[![GitHub license](https://img.shields.io/github/license/0rtis/dfktools.svg?style=flat-square)](https://github.com/0rtis/dfktools/blob/master/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/0rtis?style=flat-square)](https://github.com/0rtis)
[![Join Discord](https://img.shields.io/discord/932350221256638564?label=discord&style=flat-square)](https://discord.gg/BMWKgZSXqJ)
[![Join Discord](https://img.shields.io/discord/889216073906405507?label=discord&style=flat-square)](https://discord.gg/JvfPpV7but)
[![Follow @twitter handle](https://img.shields.io/twitter/follow/Knockturn_io.svg?style=flat-square)](https://twitter.com/intent/follow?screen_name=ortis95)


Install with `pip install dfktools`

https://pypi.org/project/dfktools/

## DefiKingdoms toolbox

This is a simple toolbox to interact with the contracts of [DefiKingdoms](https://defikingdoms.com/)

*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.*

<br/>

**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](https://discord.gg/JvfPpV7but)*

### Code guidelines
1. Indent with Tab
2. 1 empty line within a function, 2 empty lines between function
3. Use *trait(s)* to name any or all of the 8 value `strength, agility, intelligence, wisdom, luck, vitality, endurance, dexterity`
4. Use *ability(ies)* to name any or all of the 4 value `passive1, passive2, active1, active2`
5. Use *stat(s)* as a generic term for any or all the characteristics of a hero (traits, abilities, HP, MP, stamina, etc)
6. A function should support all realms, except if contracts differs across realms
7. All hardcoded addresses should be [CheckSummed](https://ethsum.netlify.app/)
8. Use `logging`, not `print`
9. No other third-party libraries (if really needed, please explain why in the PR)
10. A short & meaningful comment is better than a long & unfathomable documentation

<br/>

### Hero contract
The hero contract is accessible with [hero/hero.py](src/dfktools/hero/hero.py)

#### Quickstart
[hero_example.py](src/dfktools/hero_example.py)

#### 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](src/dfktools/profile/profile_v2.py)

#### Quickstart
[profile_example.py](src/dfktools/profile_example.py)

#### 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](src/dfktools/summoning/summoning.py)

#### Quickstart
[summoning_example.py](src/dfktools/summoning_example.py)

#### 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](src/dfktools/genes/gene_science_v2.py)

#### Quickstart
[genes_example.py](src/dfktools/genes_example.py)

#### 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](src/dfktools/auctions/hero/sale_auctions.py)
The hero rent auction contract is accessible with [auctions/hero/rent_auctions.py](src/dfktools/auctions/hero/rent_auctions.py)
Generic sale auction (ex: land) contract are accessible with [auctions/auction.py](src/dfktools/auctions/auction.py)

#### Quickstart
[auction_example.py](src/dfktools/auction_example.py)
[land_example.py](src/dfktools/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](src/dfktools/quests)

#### Quickstart
[quest_example.py](src/dfktools/quest_example.py)

#### 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
[wishing_well_quest_example.py](src/dfktools/wishing_well_quest_example.py)


### DEX & tokens
In game tokens and AMM exchange are available in module [dex](src/dfktools/dex)

#### Quickstart
[dex_example.py](src/dfktools/dex_example.py)

#### 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](src/dfktools/meditation/meditation.py)

#### Quickstart
[meditation_example.py](src/dfktools/meditation_example.py)

#### 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](src/dfktools/duel)

#### Quickstart
[duel_example.py](src/dfktools/duel_example.py)


### Raffle master
All raffle contracts are located in module [raffle](src/dfktools/raffle)

#### Quickstart
[raffle_example.py](src/dfktools/raffle_example.py)


### Pets
All pet related contracts are located in module [pets](src/dfktools/pets)

Use [pet.py](src/dfktools/pets/pet.py) to manage pet NFT

Use [hatchery.py](src/dfktools/pets/hatchery.py) to hatch pet egg

Use [exchange.py](src/dfktools/pets/exchange.py) to exchange 2 pets for an egg

#### Quickstart
[pet_example.py](src/dfktools/pet_example.py)

### Bridge
All bridge contracts are located in module [bridge](src/dfktools/bridge)

**Be careful to not mix up RPCs when dealing with multichain transaction**

#### Quickstart
[bridge_example.py](src/dfktools/bridge_example.py)




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/0rtis/dfktools",
    "name": "dfktools",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "blockchain,web3,NFT,etherum,game",
    "author": "Ortis",
    "author_email": "Ortis <ortis@ortis.io>",
    "download_url": "https://files.pythonhosted.org/packages/2f/a5/32244e266081f9e57076e9c57827a40e28ccd1f39c53fe72cc34304ac2a7/dfktools-0.3.1.tar.gz",
    "platform": null,
    "description": "\n[![Pypi_repo](https://img.shields.io/pypi/v/dfktools?style=flat-square)](https://pypi.org/project/dfktools/)\n[![GitHub license](https://img.shields.io/github/license/0rtis/dfktools.svg?style=flat-square)](https://github.com/0rtis/dfktools/blob/master/LICENSE)\n[![GitHub stars](https://img.shields.io/github/stars/0rtis?style=flat-square)](https://github.com/0rtis)\n[![Join Discord](https://img.shields.io/discord/932350221256638564?label=discord&style=flat-square)](https://discord.gg/BMWKgZSXqJ)\n[![Join Discord](https://img.shields.io/discord/889216073906405507?label=discord&style=flat-square)](https://discord.gg/JvfPpV7but)\n[![Follow @twitter handle](https://img.shields.io/twitter/follow/Knockturn_io.svg?style=flat-square)](https://twitter.com/intent/follow?screen_name=ortis95)\n\n\nInstall with `pip install dfktools`\n\nhttps://pypi.org/project/dfktools/\n\n## DefiKingdoms toolbox\n\nThis is a simple toolbox to interact with the contracts of [DefiKingdoms](https://defikingdoms.com/)\n\n*This software is not endorsed by, directly affiliated with, maintained, authorized, or sponsored by the DefiKingdoms team.\nAll product and company names are the registered trademarks of their original owners.\nThe 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.*\n\n<br/>\n\n**Like this project ? Consider supporting future developments by:**\n- Delegating AVAX to our Avalanche node **NodeID-4btZGj8TmrycK22kwgBK5wJEFighAFWiZ**\n- Making a donation to **0xA68fBfa3E0c86D1f3fF071853df6DAe8753095E2**\n\n*Need help ? Join the [GameFi Developers Discord](https://discord.gg/JvfPpV7but)*\n\n### Code guidelines\n1. Indent with Tab\n2. 1 empty line within a function, 2 empty lines between function\n3. Use *trait(s)* to name any or all of the 8 value `strength, agility, intelligence, wisdom, luck, vitality, endurance, dexterity`\n4. Use *ability(ies)* to name any or all of the 4 value `passive1, passive2, active1, active2`\n5. Use *stat(s)* as a generic term for any or all the characteristics of a hero (traits, abilities, HP, MP, stamina, etc)\n6. A function should support all realms, except if contracts differs across realms\n7. All hardcoded addresses should be [CheckSummed](https://ethsum.netlify.app/)\n8. Use `logging`, not `print`\n9. No other third-party libraries (if really needed, please explain why in the PR)\n10. A short & meaningful comment is better than a long & unfathomable documentation\n\n<br/>\n\n### Hero contract\nThe hero contract is accessible with [hero/hero.py](src/dfktools/hero/hero.py)\n\n#### Quickstart\n[hero_example.py](src/dfktools/hero_example.py)\n\n#### Transfer\nTransfer a hero from one address to another\n\n#### Info\nHero's data can be retrieved with the `get_hero` method. A more *human-friendly* format can be generated \nby passing the result of `get_hero` to the `human_readable_hero` method.\n\n#### Owner\nThe owner of a hero can be retrieved with the method `get_owner`\n\n\n### Profile contract\nThe profile contract is accessible with [profile/profile_v2.py](src/dfktools/profile/profile_v2.py)\n\n#### Quickstart\n[profile_example.py](src/dfktools/profile_example.py)\n\n#### In-game profile\nIn-game profile can be retrieved with the `get_profile` method\n\n\n### Summoning contract\nThe summoning contract is accessible with [summoning/summoning.py](src/dfktools/summoning/summoning.py)\n\n#### Quickstart\n[summoning_example.py](src/dfktools/summoning_example.py)\n\n#### Create crystal\nSummoning crystal are created with `summon_crystal` method\n\n#### Crystal id\nCrystal id can be retrieved with `get_user_crystal_ids` method\n\n#### Open summoning crystal\nSummoning crystal can be open with `open_crystal` method\n\n#### Rent auction\nPut a hero up for hire with `put_hero_for_rent`  and cancel with `cancel_rent`\nUse `is_on_rent` and `get_rent_auction` to monitor auction\n\n\n### Gene science contract\nThe gene science contract is accessible with [genes/gene_science_v2.py](src/dfktools/genes/gene_science_v2.py)\n\n#### Quickstart\n[genes_example.py](src/dfktools/genes_example.py)\n\n#### Mix genes\nStatistics and visual of summoned hero can be forecasted with the `mix_genes` method.\nNote that `mix_genes` is pseudo random and the resulting traits will be different for each block.\nHowever, a statistical analysis can be used to optimize the summoning of desirable traits\n\n### Auction contract\nThe hero sale auction contract is accessible with [auctions/hero/sale_auctions.py](src/dfktools/auctions/hero/sale_auctions.py)\nThe hero rent auction contract is accessible with [auctions/hero/rent_auctions.py](src/dfktools/auctions/hero/rent_auctions.py)\nGeneric sale auction (ex: land) contract are accessible with [auctions/auction.py](src/dfktools/auctions/auction.py)\n\n#### Quickstart\n[auction_example.py](src/dfktools/auction_example.py)\n[land_example.py](src/dfktools/land_example.py)\n#### Sale auction\n`bid_hero` and `get_auction` interact directly with the contract.\n\n`get_recent_open_auctions` and `get_hero_open_auctions` use Graphql.\n\n#### Rent auction\n`get_recent_open_auctions` and `get_hero_open_auctions` use Graphql.\n\n\n\n### Quest\nAll quest contracts are located in module [quests](src/dfktools/quests)\n\n#### Quickstart\n[quest_example.py](src/dfktools/quest_example.py)\n\n#### Foraging & Fishing quest\nEach quest requires at least 7 stamina to complete. Check the current stamina of any given hero with `get_current_stamina`.\nStart the quest with `start_quest`. The second parameter is the number of attempt. To optimize the cost of gas, it is recommended\nto use a hero at full stamina and do 3 attempts every call.\n\nUses V2 quest\n\n\n#### Gardening & Mining quest\nGardening and mining quest can be started with just one stamina. \nMining 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).\n\nUses V1 quest\n\n#### Legacy wishing well quest\n[wishing_well_quest_example.py](src/dfktools/wishing_well_quest_example.py)\n\n\n### DEX & tokens\nIn game tokens and AMM exchange are available in module [dex](src/dfktools/dex)\n\n#### Quickstart\n[dex_example.py](src/dfktools/dex_example.py)\n\n#### Balance of token\nUse `dex.erc20.balance_of` to retrieve the balance of an item for the specified address\n\n#### Liquidity pool\nUse wrapper class `dex.uniswap_v2_pair.UniswapV2Pair` and call  `expected_amount0` to get the estimated amount of `token0` received in exchange of `token1`.\nAlternatively, call `dex.uniswap_v2_router.quote`\n\n#### Swap token\nUse call `dex.uniswap_v2_router.swap_exact_tokens_for_eth` to swap erc20 token for ONE.\nUse call `dex.uniswap_v2_router.swap_exact_tokens_for_tokens` to swap erc20 tokens for other erc20 tokens.\n\n#### Staking pool\nUse wrapper class `dex.master_gardener.Garden` to retrieve staking pool info\n\n\n### Meditation circle\nMeditation circle contract is accessible with [meditation/meditation.py](src/dfktools/meditation/meditation.py)\n\n#### Quickstart\n[meditation_example.py](src/dfktools/meditation_example.py)\n\n#### Hero level up\nUse `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`\n\n\n### Duel\nAll duel contracts are located in module [duel](src/dfktools/duel)\n\n#### Quickstart\n[duel_example.py](src/dfktools/duel_example.py)\n\n\n### Raffle master\nAll raffle contracts are located in module [raffle](src/dfktools/raffle)\n\n#### Quickstart\n[raffle_example.py](src/dfktools/raffle_example.py)\n\n\n### Pets\nAll pet related contracts are located in module [pets](src/dfktools/pets)\n\nUse [pet.py](src/dfktools/pets/pet.py) to manage pet NFT\n\nUse [hatchery.py](src/dfktools/pets/hatchery.py) to hatch pet egg\n\nUse [exchange.py](src/dfktools/pets/exchange.py) to exchange 2 pets for an egg\n\n#### Quickstart\n[pet_example.py](src/dfktools/pet_example.py)\n\n### Bridge\nAll bridge contracts are located in module [bridge](src/dfktools/bridge)\n\n**Be careful to not mix up RPCs when dealing with multichain transaction**\n\n#### Quickstart\n[bridge_example.py](src/dfktools/bridge_example.py)\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 Ortis (ortis@ortis.io)  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A toolbox for DefiKingdoms",
    "version": "0.3.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/0rtis/dfktools/issues",
        "Homepage": "https://github.com/0rtis/dfktools"
    },
    "split_keywords": [
        "blockchain",
        "web3",
        "nft",
        "etherum",
        "game"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "159af82656858b629bb9a7cfecaccfd4e11a2aa0b0277f6d0915bb1f8b2e7436",
                "md5": "26b0933f254b0dccca48030f178c4c99",
                "sha256": "b00ae9b930156aefe31bc8891d59b4854fd10ef3318277795d232bcfe56da4b9"
            },
            "downloads": -1,
            "filename": "dfktools-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "26b0933f254b0dccca48030f178c4c99",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 146149,
            "upload_time": "2023-05-29T11:41:16",
            "upload_time_iso_8601": "2023-05-29T11:41:16.326192Z",
            "url": "https://files.pythonhosted.org/packages/15/9a/f82656858b629bb9a7cfecaccfd4e11a2aa0b0277f6d0915bb1f8b2e7436/dfktools-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2fa532244e266081f9e57076e9c57827a40e28ccd1f39c53fe72cc34304ac2a7",
                "md5": "94b9872568522e5c63afc410b3ba2019",
                "sha256": "82f1b4753128d4b8efcd54c4f5c15c2bbba2bda1ebcb5074d6651c14c47cfcea"
            },
            "downloads": -1,
            "filename": "dfktools-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "94b9872568522e5c63afc410b3ba2019",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 104537,
            "upload_time": "2023-05-29T11:41:19",
            "upload_time_iso_8601": "2023-05-29T11:41:19.325178Z",
            "url": "https://files.pythonhosted.org/packages/2f/a5/32244e266081f9e57076e9c57827a40e28ccd1f39c53fe72cc34304ac2a7/dfktools-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-29 11:41:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "0rtis",
    "github_project": "dfktools",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "dfktools"
}
        
Elapsed time: 0.08046s