Skip to content

Instantly share code, notes, and snippets.

View caffeinum's full-sized avatar
🐶
Coffee Driven Development

Aleksey Bykhun caffeinum

🐶
Coffee Driven Development
View GitHub Profile
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
interface IAI {
function chat(string calldata systemPrompt, string calldata message) external returns (string memory);
}
contract AIAgent {
string public constant AI_PROMPT =
"You are a business manager of this DAO treasury. "
import type { KernelAccountClient, KernelSmartAccount } from "@zerodev/sdk";
import type { Account, Chain, Transport, WalletClient } from "viem";
import { getPublicClient, type SupportedChainId } from "~/utils/publicClient";
export function pretendWalletClient(
kernelAccountClient: KernelAccountClient<
"0x0000000071727De22E5E9d8BAf0edAc6f37da032",
Transport,
Chain,
// use at https://gate-rinkeby.buildship.dev/deploy/...
// when contract address isnt fetched from tx properly
const verifyContract = address => {
const [,hash] = window.location.href.match(/deploy\/(\w+)/)
localStorage.deployedContracts = JSON.stringify({ ...JSON.parse(localStorage.deployedContracts), [hash]: address })
window.location.reload()
@caffeinum
caffeinum / README.md
Last active March 10, 2022 15:06
Download NFT Holders
  1. Download JSON with Moralis API https://github.com/nft-api/nft-api#getnftowners
  2. Use jqplay or jq command line to create csv list https://jqplay.org/
export NFT_ADDRESS = ...
curl -X 'GET' \
  'https://deep-index.moralis.io/api/v2/nft/$NFT_ADDRESS/owners?chain=eth&format=decimal' \
  -H 'accept: application/json' \
  -H 'X-API-Key: YOUR_API_KEY' \
| jq --raw-output '.result[] .owner_of' &gt; holders.csv
{
"0x3C7Cf88eA97cF9e8a74cdB22b81811092c027211": [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
@caffeinum
caffeinum / force_update_opensea.js
Last active February 12, 2022 05:47
Force Update Opensea
// use this on https://api.opensea.io/api/v1/
// in browser console
const startIndex = 0 // use to skip N first
const collection = "0x78569146f5635a31dd2ce08ea614360e8be7315d"
const getOpenSeaURL = id => `https://api.opensea.io/api/v1/asset/${collection}/${id}?force_update=true`
DELAY = 200 // ms
did:3:kjzl6cwe1jw145aodppl0512hfsnars2sd8tf49iz838r92wkwvc222k4vgiklu
@caffeinum
caffeinum / README.md
Last active November 18, 2021 04:29
Deploy AvatarNFT

Deploy your NFT sale with AvatarNFT.sol from buildship.dev

We also take 5% cut on each withdraw.

@caffeinum
caffeinum / deploy.js
Last active September 20, 2022 17:38
How to use Truffle to replace pending transaction when you deploy new contract
const Greeter = artifacts.require("Greeter");
module.exports = async function (deployer, network, accounts) {
// await deployer.deploy(Greeter);
// replace with:
const [ owner ] = accounts;
const lastNonce = await web3.eth.getTransactionCount(owner);
// this DOESN'T include pending transactions, so lastNonce + 1 always replaces pending
@caffeinum
caffeinum / [email protected]
Last active October 23, 2021 10:42
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=089cf9d1a5fcb80a0a766ebe8584656e
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.