Skip to content

Instantly share code, notes, and snippets.

@zh
zh / scanner_contracts.md
Last active September 15, 2021 13:01
Balance Scanner contracts

Include library

const { getEtherBalances, getTokenBalances } = require("@mycrypto/eth-scan");

Testnet - 0x3c72F876E5C6d02315Ba6e3a39F2f10862FE98FC

getEtherBalances('http://35.220.203.194:8545',
This post links my 3Box profile to my Github account! Web3 social profiles by 3Box.
✅ did:3:bafyreihpzmkt3a5e6duwxqd4cqvtux6b4737m7a5b45cd7obvp735axnqy ✅
Create your profile today to start building social connection and trust online at https://3Box.io/
const fromSlpAddress = 'simpleledger:q... put your wallet SLP address here ...'
const fromWIF = 'K... put your wallet private key here ...'
const childNFT = {
group: '--- put your group TXID here',
name: 'Some NFT Token Name',
ticker: 'NFT.FROG',
uri: 'Qm... put your Pinata hash here'
}
@zh
zh / ipfs_image.js
Created March 17, 2021 07:16
Display IPFS images
const waifuPrefix = 'https://icons.waifufaucet.com/original/';
const ipfsPrefix = 'https://ipfs.io/ipfs/';
if (token.symbol.toLowerCase() === 'waifu')
return `${waifuPrefix}${token.id}.png`;
if (token.uri && token.uri.startsWith('Qm'))
return `${ipfsPrefix}${token.uri}`;
diff --git a/lib/tokens.js b/lib/tokens.js
index 1a76a8a..6fd3fc1 100644
--- a/lib/tokens.js
+++ b/lib/tokens.js
@@ -61,7 +61,7 @@ class Tokens {
utxos.forEach(utxo => {
// Skip if this is not a valid token UTXO.
- if (!utxo.isValid) return
+ if (!utxo.isValid || utxo.utxoType !== 'token') return
@zh
zh / get_scores.js
Last active January 20, 2021 13:28
Get CP2021 team scores
const axios = require('axios');
const slpdbUri = 'https://slpdb.fountainhead.cash/q/';
const btoa = function (str) {
return Buffer.from(str).toString('base64');
};
const slpList = [
'simpleledger:qrr7ye5gtemkn6stvnfhh762g234tc4c2sqhruyr2f',
'simpleledger:qrt9q69sypxxaypugxptaaz57l4gnq0x4yvl0ns0f2',
@zh
zh / nft_group.js
Created January 11, 2021 05:48
Generate Group NFT
const fromSlpAddress = 'simpleledger:--wallet address here---'
const fromWIF = 'Kw--wallet-WIF-here---'
const tokenAmount = 1000
async function genGroupNFT (from, fromWif, amount) {
try {
// const balances = await bchdNetwork.getAllSlpBalancesAndUtxos(fromBchAddress)
const balances = await bchdNetwork.getAllSlpBalancesAndUtxos(from)
console.log(`balances: ${JSON.stringify(balances, null, 2)}`)
console.log("BCH balance:", balances.satoshis_available_bch)
const currentAddress = 'simpleledger: ....'
const to = 'simpleledger:....'
const balances = await bchdNetwork.getAllSlpBalancesAndUtxos(currentAddress)
const bchBalances = balances.nonSlpUtxos
let bchUtxos = []
bchBalances.forEach((j) => j.wif = wifs[currentAddress])
bchBalances.forEach((txo) => bchUtxos.push(txo))
@zh
zh / 502_error.md
Last active December 9, 2020 02:57

Code

const fromBchAddress = 'bitcoincash:qzkrtx54agr74kxduuz3me4a2p2v7z74psgg9lkl5q'
const bitbox = new BITBOX()
const client = new GrpcClient({url: 'bchd.ny1.simpleledger.io' })
const validator = new slpjs.BchdValidator(client, console)
const bchdNetwork = new slpjs.BchdNetwork({ BITBOX: bitbox, client, validator })

async function genGroupNFT (from, fromWif) {

Code

const fromSlpAddress = 'simpleledger:qp...'
const fromWIF = 'Kw...'
const toSlpAddress = 'simpleledger:qp...'

// Group NFT
const TOKENID = '4c689b3e716764aa76df2edd6c0ffd3932d16a826c7fca8bb28473d9f23d3329'