Skip to content

Instantly share code, notes, and snippets.

@sungkhum
sungkhum / gist:c745ccb6b6e2d2e80858f5ebf2c85cde
Created March 8, 2024 17:58
DeSo Protocol JS Snippet for Transferring DAO Token
// NOT WORKING CODE - just a snippet to get the general idea
import {
identity, transferDeSoToken
} from "deso-protocol";
try {
// Permission checks and setup
if (!identity.hasPermissions({
TransactionCountLimitMap: {
NEW_MESSAGE: "UNLIMITED"
@sungkhum
sungkhum / cc_calc.py
Created February 2, 2024 04:13
Calculate DeSo Historical Creator Coin Price
# This only calculates the locked deso for now
'''
The DeSo GraphQL Queries:
Creator Coin Buys/Sells (you'll need the base64 publickey for that): https://graphql-prod.deso.com/?explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QEcYIE4CeABAIq6EAUAJAGYCWeAziukQJKoA0RVAhjSnysAwjCYQ83WnQA2gvKwCCNGgiiCwABRgAjGXSgBpBAQBis%2BVIlh8AIQKsA2stXqEW3fqMnGAeTw2ePYAhAC6UlAQSGB0KHRRSipqGtp6BsYEwlExcVEAlETAADpIRGVE-K4pnuk%2BFPRyQjwNlkT0TCzNDMzc-PKsfAL43NZ2DjyjQQTckdGx8UgDszkLBcWl5WVIEDaMhSWbmyh4vEiMvOoL%2BxuH5SgAHkgAKgQADggHt3f3HDb3ALIIFC8MC8YGfL5EOKIZi8OCvCFfV41bwERG3B5IQHgm5fVQIABypwgjHR5QAvmSytCELD4WTKbiyq9eABzBAcGgQa6Q5BgUTiPBUogAC14jAJCHuKE0bI%2BTKIjM2SsVIE4IAAbrw8HReHpaRgQOsykUQO1mKbWABWAAMds4n1NfXwlqISBgMhkDo2ppaLowPPKpuRaVRruNh1NCBwvBkTwgrtNtmEAEYAJoAGVZrzwEBoAFUAEoAJgAysISBnbBBXgSkAAJABWAHYRVBTHACXQnsWAMwALS5ADY00gABoAUUMpag-cMmjoWhIOgA7mPTYjyd7NqbMS93uGyVGY3GEwGUynN9ugyBjqdzpcooeFbvHtjeM-IabZsC6GdP5CRCmpouYNAgqReBkiYgIorysjowj-JoQ4ANaaFgvg6Ioxb5v8KBwFAYAAOoAOKmAALIwAAijDRAAXgAUvWRH3HgrwAJzFihigAPRMBuCplCqyqbp8W6OiAkz2NBTxsP8
@sungkhum
sungkhum / message.jsx
Created January 29, 2024 16:35
How to send a new direct message with Deso-protocol js
// Using https://github.com/deso-protocol/deso-js
//////////////////////////////
// Derived Key looks like this:
//////////////////////////////
if (
!identity.hasPermissions({
TransactionCountLimitMap: {
NEW_MESSAGE: "UNLIMITED"
},
})
@sungkhum
sungkhum / getDeSoUserData.py
Last active September 3, 2023 00:52
A Python script using GraphQL to get the social graph of DeSo users for data processing
import json
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
import time
# Get transactions and info on account:
# https://graphql-prod.deso.com/?explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QEcYIE4CeABAIJRQQyoBCBAqgM75ICGiAFACQxN6uLoiAZRR4AlkgDmAQgCURYAB0kRIi3KUa9XvwTsezNgkHcdR%2BUpWqiABxgAjADZioAaQQEANMutEDfI28rVTAEBihxGxQxCCQg31CGCGoWRxYkKAQFH18ie1T0zIA5dIgGHNUAXwqicgBhCAkGAEkkOrE8WDTo2JKkMpqKCQAFcUyAETCIPoHg2rwEFhQIPBSGMQZhxtRyuYjF5bwGiRS0jLDsudVllFSGqhQa6r2FpZXjpFPCsJIGOtfDpdckQbndNI85s8EvgxAA3BBgdwEBhA3Kgxz3VBPQbbADqS3wcBYeAA1jNdtCkgAZaAkhHkmpgMRsWJgBgAJQQmThCNRvnRmIhvih1iZLKQbKEyBQfOsAvB2LmADMII5HBAAO74FGWYHyh6K3wqtWaiSSWXXCC3DEKyE1RwISTqAgAWTCDBYkjCnO58LAFpBVrBBrtcwdTqgrvdnrCUtQAf1WNDvmcdJ1NUt1sFhusiAYHq9HK5CB5-t1aKDNpDwpqeYLselCcr2eT1iQSpQ1DEbKbWdtNbm7ZQDF%2BVJYDBQAHkNUh8L3g0mB74hwxp7OyxnA33q9YRap-L8klBmT0kCOGAAVYlemXl-nN-u7mo2MooQ-QE8xM-zquLp9zA98w-JYv3PC88HSD0oEBO85QfHcqmfV90yuLcFyFf9%2BQgs91FPFDgX6RIA2ubCoNPC8CBsLJYIIoxN0Q1DVAkOxh3oogEAAD1EFhxiWFg2KVBAEAZRi
@sungkhum
sungkhum / sign.py
Created April 18, 2023 00:05
Updating Signing Code for DeSo Balance Model Fork
# This file has code for signing a transaction --> Credit: MiniGlome
import hashlib
import hmac
from typing import Union
from hashlib import sha256
from secp256k1 import PrivateKey, PublicKey
import struct
class HmacDrbg:
def __init__(self, hash_len, q_byte_len):
@sungkhum
sungkhum / desodiamond.py
Last active December 22, 2022 05:21
Mass Diamond Shower Python Script for DeSo Blockchain
#################################
#
# Mass Diamond Shower Script
# by https://diamondapp.com/u/nathanwells
#
# Uses DeSo Python Library
# https://pypi.org/project/deso/
# by https://diamondapp.com/u/ItsAditya
#
#################################
@sungkhum
sungkhum / gist:ed72eb1f74a044cde77dc7d6b6d2b9ba
Created March 23, 2022 18:25
DeSo NFT Auto Mint and Transfer from CSV using ArWeave Image Storage
# Script to mint DeSo NFTs from CSV file using ArWeave image storage
import arweave
import logging
from arweave.transaction_uploader import get_uploader, logger
import requests
from PIL import Image
import os, tempfile, zipfile
import csv
import shutil
import deso
@sungkhum
sungkhum / nftimages.py
Last active February 13, 2022 23:38
Script to download and convert NFT images from various sources
# Script to download and convert NFT images from varies sources
import os
import csv
import requests
import shutil
from PIL import Image
# Create images directory if it doesn't exist
if not os.path.exists('./images'):
os.mkdir('./images')
@sungkhum
sungkhum / bitclout-deso-upload-image.py
Created October 25, 2021 17:37
Upload image to BitClout DeSo Diamond in Python for use in a post
import jwt #pip install pyjwt
import os
import requests
import binascii
import json
from ecdsa import SigningKey, SECP256k1
from io import BytesIO
''' SEEDHEX should always be kept private. It has access to your complete wallet. It's kinda like
seed phrase. This is why writing methods in backend isn't a good practice until we have derived keys.
@sungkhum
sungkhum / jwt.py
Last active May 24, 2022 04:26
Generate JWT from SEEDHEX for BitClout DeSo in Python
import jwt
import binascii
from ecdsa import SigningKey, SECP256k1
''' SEEDHEX should always be kept private. It has access to your complete wallet. It's kinda like
seed phrase. This is why writing methods in backend isn't a good practice until we have derived keys.
You can only automate your own account and can't have user authorisation. It is recommended to use test account while using write methods.
You can find the seedHex of your account in your browser storage. Just open https://bitclout.com/ > Dev tools > Application > Storage > Local Storage > https://identity.bitclout.com > users > Select the public key with which you want to post > seedHex'''