Repository
https://github.com/nnmix/py-primedice-bot
What Will I Learn?
- You will learn to automate a PrimeDice Bot given your own rules
- You will learn to use Python: 'requests' and 'json' libraries
- You will learn to use your Prime Dice Account Token
- You will learn to fetch your account details: Coins / Balance
- You will learn to execute automated 'Rule Based' dice rolls
Requirements
Β Personal Prerequisite
- Existing primedice account
Β System prerequisites:
- Jupyter notebook for python
Β Knowledge prerequisites:
- Basic understanding of python programming
- Basic understanding of Http Methods, APIs
Difficulty
- Intermediate
Description
In this tutorial you will get the ability to automate your own flavored Dice Roller Bot on your prime dice account
Content
Before getting to the python scripting section you will need the primedice account token to be used in the http method calls.
Β 1. Primedice Account Token:
Β Β a. Sign in to your existing primedice account
Β Β b. Go to MORE > SETTINGS > TOKENS > REVEAL > Copy
Β Β Β Β Β Β Β
Β 2. Jupyter / Python
You can access jupyter Online or Intall it locally on your pc.
When done open a new python file:
When the file is open, if you are on the online version, you can delete existing sample cell by clicking the cell border (blue highlight) than double pressing 'D'
Until you have an empty cell to write your script within:
Now your jupyter editor is up you can start typing your code and run it by pressing ctrl+enter
Β 3. Dice Roller/ Python
Let us start talking about the prime dice roller implementation
- Primedice API URL is
https://api.primedice.com/graphql
- HTTP Request Header should contain the account token
'x-access-token' : 'your prime dice account bet token'
- Post Request Data:
e.g. to get the list of coins balances (operation name is Balances):
[{
"operationName": "Balances",
"variables": {
"available": true
},
"query": "query Balances($available: Boolean = false, $vault: Boolean = false) {\\n user {\\n id\\n balances {\\n available @include(if: $available) {\\n currency\\n amount\\n __typename\\n }\\n vault @include(if: $vault) {\\n currency\\n amount\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n}\\n"
}]
- Executing The API call in python
e.g.
# requests lib
import requests
# api url
api = 'http://me.api.com'
# http headers
headers = {
'content-type': 'application/json',
'x-access-token': '<token-access-keys>'
}
# http request post raw data
data = '{ "param" : "value" }'
# invoke api call and get the response
response = requests.post('api url', headers= httpHeader, data= postData)
Now on the prepared python functions to use are:
def headers()
within this function replace <token-access-keys> with your own keysdef balance(coin)
call it to get the balance in Satoshi Units
-- supported coins in primedice are btc, ltc, bch, doge, eth.
-- e.g.satoshis = balance('btc')
def roll(amount, condition, target, coin)
call it to run a dice roll
-- pass the amount in satoshis unit
-- your bet target condition 'above' or 'below'
-- your desired dice target number range ] 0, 100 [
-- returns success (true or false), result (dice number result), payout (0 on loss, on win it is the total payout including the bet amount)
-- e.g. bet amount of 100 satoshis for a roll target above 70:
success, result, payout = roll(100, 'above', 70, 'btc')
The End!
Finally most of the steps are covered, it is your time to configure your own rules / algorithm that may give you your optimal winning payouts.
Feel free to share and list your own automation python bot script on the project github project page with your fresh good results for others to try !
Related
Proof of Work Done
https://github.com/nnmix/py-primedice-bot/blob/master/main.py
Thank you for your contribution @aro.steem.
After reviewing your tutorial we suggest the following points listed below:
Your tutorial is quite short for a good tutorial. We recommend you aim for capturing at least 2-3 concepts.
We suggest that in the next tutorial detail plus what you are explaining.
Using GIFs to show results is definitely better than standard still images.
Thank you for your work in developing this tutorial.
Looking forward to your upcoming tutorials.
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Chat with us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hi @portugalcoin,
Thank you for your advices, push and boost.
Actually yes thats my first tutorial here and it is more like a quicky, i hope next times i will develop and expend it more. Cheers π»
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you for your review, @portugalcoin! Keep up the good work!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hi @aro.steem!
Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thank you very much @steem-ua, i will join the discord server soon π
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey, @aro.steem!
Thanks for contributing on Utopian.
Weβre already looking forward to your next contribution!
Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thank you @utopian-io for all your works and efforts.
Witness Upvoted πΊ
https://steemd.com/tx/ed6c7f522e1b65fb5b2c0b6c32a474cc12b9c0e1
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
hi bro
i have a script which is previously works good but from last some days its giving graphql connection error
can you fix it
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit