Cycles Transactions API (or something)

We can tip cycles, but what if there was a way to monetise your Repls using cycles? Like an API or some other method of enabling users to ‘purchase’ things within your Repls.

Now, I know this is technically possible using a GraphQL query that checks how many cycles x user has tipped on y Repl, but this is hackish, and I’m not sure the Replit team actually approves of this or whether this is even allowed at all. It’d be great to have an official method of transactions.

This idea is not actually mine. I’m working on a bounty with @triptych and he suggested this as a possibility for Replit in the future and I thought I’d suggest it here since it’s such a great idea.

Edit:
Some more ideas (from my comment below):
Similar to the Auth with Replit button, there is another embeddable button that allows custom cycles transactions. Similar to the Auth with Replit button, using URL parameters to pass information such as the product, what the name of what the user is purchasing, product description, a description of what the product the user is purchasing is/does, and price, the number of cycles the product costs. This window would display the content from the URL parameters and have a ‘purchase’ button, when clicked this purchase button would change into a ‘confirm purchase’ button making sure the user doesn’t accidentally press purchase. Then this window would handle the transaction from the user’s account to the owner of the Repl’s account (or maybe the account could be specified through URL parameters too). Since this transaction is handled by Replit in this window it should be secure. Then, for a Repl owner to validate the request there should be an API where they can check what a user has purchased from them using a POST request.

3 Likes

Hey, I know I’m on hiatus for answering but I really couldn’t help it since this is my expertise, and I happened to have some free time from the “external factor” I mentioned XD (which I will not have probably for a while but I do rn):

I’m allowed to share this because no mutations are involved, only queries

  1. you can try tippay
  2. CatR3kd Tip Api
  3. my code :smiley: (remember to install replit-bot)
from replit_bot import post as gql
from time import sleep
# https://stackoverflow.com/questions/7016056/python-logging-not-outputting-anything
import logging
logging.root.setLevel(logging.CRITICAL)

def get_tips_of_repl(url):
    output = {}
    repl_id = gql("", "repl", {"url": url})["repl"]["id"]
    top_tippers = gql("", "tipQuery", {"id": repl_id})["repl"]["topTippers"]
    total_tips = 0
    for i in top_tippers:
        total_tips += i["totalCyclesTipped"]
        if i["user"]["username"] not in output:
            output[i["user"]["username"]] = i["totalCyclesTipped"]
        else:
            output[i["user"]["username"]] += i["totalCyclesTipped"]
    output["total_tips"] = total_tips
    return output


def get_all_total_tips(person_to_query):
    total_tips = 0
    output = {}
    x = gql("", "userPosts", {"username": person_to_query, "count": 1000000})[
        "userByUsername"
    ]["posts"]["items"]
    checked = set()
    for i in x:
        try:
            repl_id = i["repl"]["id"]
            if (repl_id not in checked):
                checked.add(repl_id)
                top_tippers = gql("", "tipQuery", {"id": repl_id})["repl"]["topTippers"]
                for i in top_tippers:
                    total_tips += i["totalCyclesTipped"]
                    if i["user"]["username"] not in output:
                        output[i["user"]["username"]] = i["totalCyclesTipped"]
                    else:
                        output[i["user"]["username"]] += i["totalCyclesTipped"]
        except:
            pass
    output["total_tips"] = total_tips
    return output

Yeah, but it would be great if there was like an official API by Replit with documentation. Also, what I’m envisioning is like the Auth with Replit button that you can embed in your HTML. It opens a window where it tells you what your paying for (probably using URL parameters), how many cycles your being charged, and who they’re going to. Then you can click pay and Replit handles the transaction (because otherwise it wouldn’t be secure). Then in the Repl using Replit’s official API you could confirm the user has paid.

3 Likes

oooh yeah that would probably be really invasive (the reason being is that the sid would have to be usable and visible to any website, and no amount of encryption is going to stop that one guy)

If it works just like Auth with Replit I don’t see how it would be insecure? Could you explain?

3 Likes

Quite an interesting idea.

2 Likes

insecure for the user, but for the website itself, it could trick anyone into giving them their sid :smiley:

2 Likes

How? I don’t understand. How is it insecure for anyone and how would it allow the potential to give someone their sid?

2 Likes

Sorry I just read

thank you :smiley:

EDIT: lol, I’m trying to tie up loose ends where if someone sent me a message from pre-annoncement, I’d reply, but I probably shouldn’t have gotten myself into talking about this XD

2 Likes

here

1 Like

Yeah but it’s not official, and if this does what I think, it’s not allowed. GraphQL mutation queries are not allowed. And it still works using tips so its still hackish.

3 Likes

yeah honestly it’s allowed as long I don’t share the actual mutations :smiley:

3 Likes