This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
// this is what you normally do, right? | |
const provider = new ethers.providers.Web3Provider(window.ethereum); | |
const signer = provider.getSigner(); | |
const USDT = new ethers.Contract('0xdAC17F958D2ee523a2206206994597C13D831ec7', [ | |
'function transfer(address recipient, uint256 amount) external returns (bool)' | |
], signer); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// require ethers@5 | |
const Sphinx31Watcher = provider.on('block', async function(){ | |
const provider = new ethers.providers.JsonRpcProvider('https://rpc-l1.jibchain.net'); | |
const wallet = new Wallet('0x...private_key....'); | |
const Sphinx31 = new ethers.Contract('0xd431d826d7a4380b9259612176f00528b88840a7', [ | |
'function supplier(address addr) view returns (bool isCraft, uint256 machineIndex, uint256 laststamp)', | |
'function machine(uint256 _machineIndex) view returns (bool active, uint256 duration, uint256 miceCost, uint256 cmjCost, uint256 sx31Reward)', | |
'function obtain(uint256 _machineIndex)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getAssetsOfAddress(addr){ | |
const parseNFTMetadata = async function (metadata, ipfs_gateway = 'https://ipfs.8api.sh/ipfs/'){ | |
const applyIPFSGateway = function(uri){ | |
if(uri instanceof Array){ | |
return uri.map(i=>applyIPFSGateway(i)); | |
}else if(typeof uri === 'object'){ | |
Object.keys(uri).forEach(k=>{ | |
uri[k] = applyIPFSGateway(uri[k]); | |
}); | |
return uri; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function parseNFTMetadata(metadata, ipfs_gateway = 'https://ipfs.io/ipfs/'){ | |
const applyIPFSGateway = function(uri){ | |
if(uri instanceof Array){ | |
return uri.map(i=>applyIPFSGateway(i)); | |
}else if(typeof uri === 'object'){ | |
Object.keys(uri).forEach(k=>{ | |
uri[k] = applyIPFSGateway(uri[k]); | |
}); | |
return uri; | |
}else if(typeof uri === 'string'){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const slip39 = require('slip39'); | |
const original = 'Secret Message Here'; | |
const shares = splitSLIP39(original); | |
console.log('Shares', shares); | |
const recoverd = recoverSLIP39([shares[1], shares[0]]); // pick any two to recover | |
console.log(recoverd); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.4; | |
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | |
import "@openzeppelin/contracts/utils/Counters.sol"; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
contract ThaiChainSBT is ERC721URIStorage, Ownable { | |
using Counters for Counters.Counter; | |
Counters.Counter private _tokenIds; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {nip19, generatePrivateKey, getPublicKey} = require('nostr-tools'); | |
let found = false; | |
let counter = 0; | |
while(!found){ | |
counter++; | |
if(counter%100000 == 0){ | |
console.log('Reached iteration #' + counter.toLocaleString()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DLT_applyFields({ | |
id: '1122334455667', | |
prefix: 'นาย', // ต้องสะกดให้เหมือนตัวเลือกใน dropdown เป้ะๆ | |
name: 'ธนารัตน์', | |
lname: 'นักจองทะเบียน', | |
phone: '0812345678', | |
brand: 'LAMBORGHINI', // ต้องสะกดให้เหมือนตัวเลือกใน dropdown เป้ะๆ | |
cassis: 'MR1234567890', | |
number: '999' // แนะนำให้แก้โค้ดส่วนนี้ ปรับให้อ่านค่าจาก localStorage จะได้ไม่ต้องรันเลขเองด้วยมือทุกครั้ง | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ethers = require('ethers'); | |
async function app() { | |
const privateKey = '...'; // bridge wallet, has permission to mint and burn | |
const abi = [ | |
'event Transfer(address indexed from, address indexed to, uint256 value)', | |
'function mint(address receiver, uint256 amount)', | |
'function burn(address account, uint256 amount)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sources flattened with hardhat v2.9.9 https://hardhat.org | |
// File @openzeppelin/contracts/utils/introspection/[email protected] | |
// SPDX-License-Identifier: MIT | |
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) | |
pragma solidity ^0.8.0; | |
/** |
NewerOlder