GithubHelp home page GithubHelp logo

payoutscript-xyz's Introduction

PayoutScript-xyZ

  • This script will make all the payouts for your Axie Infinity academy!

Setup

Step-by-step help

  1. Please join my Discord channel : https://discord.com/invite/837cCXPd48
  2. DM our Head of IT for support

Upcoming new features

Bug to fix

  • Please tell me if you experience any bugs...

Donations

With your donation, I will be able to keep working on this project and add new features. Thank you!

  • There’s a built-in donation of 1% that you can easily modify by changing the value of FEE_PAYOUT_ADDRESS from 0.01 to 0.

  • Ronin Wallet Address: ronin:a04d88fbd1cf579a83741ad6cd51748a4e2e2b6a

  • Ethereum Wallet Address: 0x3C133521589daFa7213E5c98C74464a9577bEE01

Help

If you need help with setup or you have any question, please reach out to me!

License

The MIT License (MIT)

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.

payoutscript-xyz's People

Contributors

zrachess-xyz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

payoutscript-xyz's Issues

ERROR slp_utils.execute_slp_claim: 'NoneType' object is not subscriptable

Getting an error as below,

Would you like to claim SLP? y
Claiming 183 SLP for 'Scholar 4'... ERROR slp_utils.execute_slp_claim: 'NoneType' object is not subscriptable
DONE
Claiming 383 SLP for 'Scholar 5'... ERROR slp_utils.execute_slp_claim: 'NoneType' object is not subscriptable
DONE
Claiming 202 SLP for 'Scholar 7'... ERROR slp_utils.execute_slp_claim: 'NoneType' object is not subscriptable
DONE
Claiming 378 SLP for 'Scholar 8'... ERROR slp_utils.execute_slp_claim: 'NoneType' object is not subscriptable
DONE
Claiming 934 SLP for 'Scholar 9'... ERROR slp_utils.execute_slp_claim: 'NoneType' object is not subscriptable
DONE
Claiming 117 SLP for 'Scholar 12'... ERROR slp_utils.execute_slp_claim: 'NoneType' object is not subscriptable
DONE
Claiming 207 SLP for 'Scholar 13'... ERROR slp_utils.execute_slp_claim: 'NoneType' object is not subscriptabl
axie script
e

How do I run it on a private rpc node?

Hi there.

A 503 error has occured when I run get_claimed_slp().
I think the cause is this. https://discord.com/channels/410537146672349205/505902543927246870/903005058701066341

Hey, to clarify, the public RPC node got limited to only allow normal queries / methods. If yo try to filter or do more complicated queries, the node will automatically answer with a 403 error, to avoid a node overload as it got spammed/ddosed again.

If the public RPC doesn't meet the requirements of your script / app anymore, you can set up your own node.
Here are the instructions: https://docs.google.com/document/d/1M20n7HTOdezgM4dgFUsHGOH6Z758Bf684R3NXGPewOw/edit
For the requirements, we suggest 4 cores, 8GB RAM and 500 GB SSD. A bandwith of around 40Mb/s should be enough.

I launched private RPC node and sent request to http://127.0.0.1:8545.
But, error occurred.

web3.exceptions.BadFunctionCallOutput: Could not transact with/call contract function, is contract deployed correctly and chain synced?

How do I run it on a private rpc node?

SLP claim failing after endpoint update

I have updated the slp_utils.py script to the new endpoints and updated variables (ex. rawClaimableTotal, lastClaimedItemAt, etc). This got me through determining the SLP claim values. Once I initiate an SLP claim, the following error message occurs:

Would you like to claim SLP? y
   Claiming xxx SLP for 'ronin:xxx'...{"_error":404000,"_errorMessage":"Not Found"}

Here is a copy of my slp_utils.py:

from datetime import datetime, timedelta
from eth_account.messages import encode_defunct
from web3 import Web3
import json, requests, time

USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36"
headers = {
  "Content-Type": "application/json",
  "User-Agent": USER_AGENT }

web3 = Web3(Web3.HTTPProvider('https://api.roninchain.com/rpc', request_kwargs={ "headers": headers }))
web3_2 = Web3(Web3.HTTPProvider('https://api.roninchain.com/rpc', request_kwargs={ "headers": headers }))

with open('slp_abi.json') as f:
    slp_abi = json.load(f)
slp_contract = web3.eth.contract(address=Web3.toChecksumAddress("0xa8754b9fa15fc18bb59458815510e40a12cd2014"), abi=slp_abi)
slp_contract_2 = web3_2.eth.contract(address=Web3.toChecksumAddress("0xa8754b9fa15fc18bb59458815510e40a12cd2014"), abi=slp_abi)

def get_claimed_slp(address):
  return int(slp_contract_2.functions.balanceOf(address).call())

def get_unclaimed_slp(address):
  for _ in range(3):
    response = requests.get(f"https://game-api-pre.skymavis.com/v1/players/{address}/items/1", headers=headers, data="")
    if (response.status_code == 200):
      break
    else:
      time.sleep(1)

  if (response.status_code != 200):
    print(response.text)
  assert(response.status_code == 200)
  result = response.json()
  
  total = int(result["rawTotal"]) - int(result["rawClaimableTotal"])
  last_claimed_item_at = datetime.utcfromtimestamp(int(result["lastClaimedItemAt"]))

  if (datetime.utcnow() + timedelta(days=-14) < last_claimed_item_at):
    total = 0
  
  return total

def execute_slp_claim(claim, nonce):
  if (claim.state["signature"] == None):
    access_token = get_jwt_access_token(claim.address, claim.private_key)  
    custom_headers = headers.copy()
    custom_headers["authorization"] = f"Bearer {access_token}"
    response = requests.post(f"https://game-api-pre.skymavis.com/v1/players/{claim.address}/items/1/claim", headers=custom_headers, json="")
    if (response.status_code != 200):
      print(response.text)
    assert(response.status_code == 200)
    result = response.json()["blockchain_related"]["signature"]
    
    claim.state["signature"] = result["signature"].replace("0x", "")
    claim.state["amount"] = result["amount"]
    claim.state["timestamp"] = result["timestamp"]

  claim_txn = slp_contract.functions.checkpoint(claim.address, claim.state["amount"], claim.state["timestamp"], claim.state["signature"]).buildTransaction({'gas': 1000000, 'gasPrice': web3.toWei('1', 'gwei'), 'nonce': nonce})

  signed_txn = web3.eth.account.sign_transaction(claim_txn, private_key = bytearray.fromhex(claim.private_key.replace("0x", "")))
  web3.eth.send_raw_transaction(signed_txn.rawTransaction)

  return web3.toHex(web3.keccak(signed_txn.rawTransaction)) # Returns transaction hash.

def transfer_slp(transaction, private_key, nonce):
  transfer_txn = slp_contract.functions.transfer(
    transaction.to_address,
    transaction.amount).buildTransaction({
      'chainId': 2020,
      'gas': 100000,
      'gasPrice': web3.toWei('1', 'gwei'),
      'nonce': nonce,
    })

  signed_txn = web3.eth.account.sign_transaction(transfer_txn, private_key = bytearray.fromhex(private_key.replace("0x", "")))
  web3.eth.send_raw_transaction(signed_txn.rawTransaction)
  return web3.toHex(web3.keccak(signed_txn.rawTransaction)) # Returns transaction hash.

def sign_message(message, private_key):
    message_encoded = encode_defunct(text = message)
    message_signed = Web3().eth.account.sign_message(message_encoded, private_key = private_key)
    return message_signed['signature'].hex()

def get_jwt_access_token(address, private_key):
  random_message = create_random_message()
  random_message_signed = sign_message(random_message, private_key)

  payload = {
      "operationName": "CreateAccessTokenWithSignature",
      "variables": {
        "input": {
              "mainnet": "ronin",
              "owner": f"{address}",
              "message": f"{random_message}",
              "signature": f"{random_message_signed}"
        }
      },
      "query": "mutation CreateAccessTokenWithSignature($input: SignatureInput!) {    createAccessTokenWithSignature(input: $input) {      newAccount      result      accessToken      __typename    }  }  "
  }

  response = requests.post("https://graphql-gateway.axieinfinity.com/graphql", headers=headers, json=payload)
  if (response.status_code != 200):
    print(response.text)
  assert(response.status_code == 200)
  return response.json()['data']['createAccessTokenWithSignature']['accessToken']

def create_random_message():
  payload = {
        "operationName": "CreateRandomMessage",
        "variables": {},
        "query": "mutation CreateRandomMessage {    createRandomMessage  }  "
    }

  response = requests.post("https://graphql-gateway.axieinfinity.com/graphql", headers=headers, json=payload)
  if (response.status_code != 200):
    print(response.text)
  assert(response.status_code == 200)
  return response.json()["data"]["createRandomMessage"]

Facing issues with the script (have not changed any codes other than scholar info)

root@DESKTOP-82:/mt/c/Users/PC/Desktop/PayoutScript-xyZ-main# python3 payoutscript-xyz.py slp-payout-config.json
*** Welcome to the SLP Payout program *** (2022-03-01 23:50:01.907225)
Traceback (most recent call last):
File "payoutscript-xyz.py", line 55, in
accounts = json.load(f)
File "/usr/lib/python3.6/json/init.py", line 299, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/usr/lib/python3.6/json/init.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.6/json/decoder.py", line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 10 column 9 (char 453)
root@DESKTOP-82:/mt/c/Users/PC/Desktop/PayoutScript-xyZ-main#

How do I solve this issue?

Checking for unclaimed SLPTraceback (most recent call last):
File "PayoutScript-xyZ.py", line 71, in
nonce = nonces[account_address] = web3.eth.get_transaction_count(account_address)
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/module.py", line 57, in caller
result = w3.manager.request_blocking(method_str,
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/manager.py", line 186, in request_blocking
response = self._make_request(method, params)
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/manager.py", line 147, in _make_request
return request_func(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/middleware/formatting.py", line 76, in apply_formatters
response = make_request(method, params)
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/middleware/gas_price_strategy.py", line 90, in middleware
return make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/middleware/formatting.py", line 74, in apply_formatters
response = make_request(method, formatted_params)
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/middleware/attrdict.py", line 33, in middleware
response = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/middleware/formatting.py", line 74, in apply_formatters
response = make_request(method, formatted_params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/middleware/formatting.py", line 76, in apply_formatters
response = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.call
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/middleware/formatting.py", line 74, in apply_formatters
response = make_request(method, formatted_params)
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/middleware/buffered_gas_estimate.py", line 40, in middleware
return make_request(method, params)
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/middleware/exception_retry_request.py", line 105, in middleware
return make_request(method, params)
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/providers/rpc.py", line 88, in make_request
raw_response = make_post_request(
File "/home/yochabel/.local/lib/python3.8/site-packages/web3/_utils/request.py", line 49, in make_post_request
response.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://proxy.roninchain.com/free-gas-rpc

Script not identifying that SLP can be claimed

After running the script today, it is not identifying that the accounts has SLP to be claimed (usually it works fine).
It just says checking for unclaimed SLP ........................ and then moves to payouts where it shows all balances are zero.

Any fix?

Calls To Roninchain Being Rejected (403 Forbidden)

It appears Sky Mavis has changed some requirements on calls made to the ronin chain rpc. Now whenever a request is made this error occurs:

403 Client Error: Forbidden for url: https://proxy.roninchain.com/free-gas-rpc

This is due to a new requirement to include a user-agent in the request headers. PR incoming...

[error] Unable to execute slp_utils.execute_slp_claim

Hi, there.
I want to send SLP to scholars with these GREAT scripts.
But, I can't send because error is occured.
Do you know the solution?


as is

Unable to execute slp_utils.execute_slp_claim

to be

execute slp_utils.execute_slp_claim

environment

$ wsl lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:        20.04
Codename:       focal

$ wsl python3 --version
Python 3.8.10

$ wsl pip show web3
Name: web3
Version: 5.23.0

to reproduce

$ wsl python3 PayoutScript-xyZ.py /path/to/my/slp-payout-config.json

*** Welcome to the SLP Payout program *** (2021-08-27 01:43:11.207580)
Checking for unclaimed SLPAccount 'My Name' (nonce: 0) has 10 unclaimed SLP.
Would you like to claim SLP? y
   Claiming 10 SLP for 'My Name'...Traceback (most recent call last):
  File "PayoutScript-xyZ.py", line 115, in <module>
    slp_utils.execute_slp_claim(slp_claim, nonces)
  File "/path/to/project/PayoutScript-xyZ/slp_utils.py", line 47, in execute_slp_claim
    claim.state["signature"] = result["signature"].replace("0x", "")
TypeError: 'NoneType' object is not subscriptable

frequency

5/5

investigated

https://github.com/ZracheSs-xyZ/PayoutScript-xyZ/blob/main/slp_utils.py#L41

my response.json() is ...

{'blockchain_related': {'balance': 10,
                        'block_number': 6139656,
                        'checkpoint': 0,
                        'signature': None},
 'claimable_total': 10,
 'client_id': '0xb99af3eb1b8782b019695f6b1a2b7c4268da855d',
 'item': {'created_at': 1576669291,
          'description': 'Breeding Potion is required to breed two Axies',
          'id': 1,
          'image_url': '',
          'name': 'Breeding Potion',
          'updated_at': 1576669291},
 'item_id': 1,
 'last_claimed_item_at': 0,
 'success': True,
 'total': 10}

blockchain_related.signature is None, I don't know the cause ...

Ronin API changed ? slp_utils.get_claimed_slp() function

Hello,

I think the get_claimed_slp() function doesn't work anymore. My guess is they may have updated the API.

File "~/PayoutScript-xyZ/slp_utils.py", line 17, in get_claimed_slp

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://proxy.roninchain.com/free-gas-rpc

Thanks for your code anyway. It's life changing :)

Script doesnt work anymore

Anybody have any update with the script?

I'm always getting "Skipping account because SLP balance is zero." even if there's SLP in the account.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.