Skip to content

Instantly share code, notes, and snippets.

View 0xdeepmehta's full-sized avatar
🤿
Solana

0xDeep 0xdeepmehta

🤿
Solana
View GitHub Profile
// Define the size of each chunk
const chunkSize = 1000;
// Create a function to iterate over the items in chunks
async function iterateInChunks(items: any[], callback: (chunk: any[]) => void) {
// Calculate the number of chunks
const numChunks = Math.ceil(items.length / chunkSize);
// Create an array to hold the promises for the async operations
const promises = [];
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract AMM is ReentrancyGuard{
using Counters for Counters.Counter;
Counters.Counter private caseID;
{
header: {
numRequiredSignatures: 2,
numReadonlySignedAccounts: 0,
numReadonlyUnsignedAccounts: 2
},
accountKeys: [
PublicKey {
_bn: <BN: ac0c28f702f61dca52e1e6260991e7db6bc3abbc0956434c9cbf0046b384ed5>
},
@0xdeepmehta
0xdeepmehta / check_proton_mail_exit.js
Last active September 9, 2022 11:25
check whether username exist in proton or not
await fetch("https://account.proton.me/api/users/available?Name=0xdeepmehta%40protonmail.com&ParseDomain=1", {
"headers": {
"accept": "application/vnd.protonmail.v1+json",
"accept-language": "en-GB,en;q=0.6",
"cache-control": "no-cache",
"pragma": "no-cache",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"sec-gpc": "1",

on client side

const new_token_account =  anchor.web3.Keypair.generate();

// and on tx builder, include the new_token_account as singer
.signers([new_token_account]).rpc()
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
Accounts
4SAKbvUL9S3HqMAaiStuycCAxreKYzCEVgz5mjddS63d
9MqSqfMnFURhSK7Qouinjzs8Jei7ZfAiq3jkZa8bpwDh
HzQUHdhT6DHNr5kgNYgZtQ7cgMYi5ygc8ptBZo1k5v1Z
919mqjGT1nxig7qxUBhhzWSg9bX8vU6z1KbB2iiLT3xh
98dormQvMenmn6wZjzkgvvKNMmbSDMfaMcNrzP4GJWux
vHeXX3pKFj5f9ZgwU8zDZHJwGooXzeotho8QSCAWFTh
EEdCJ2giRpW2RyjQSJwm3rdAU7RBTSm7rWdA2iszJx3a
3wsmFazBaGpVgFR7ZZfWgiaLbmUpKAox11EKDcith6WX
HeUweiQ6vQnPeTSN9hXorCZiZpF2iZzCL8bod4kZtpiv

Keybase proof

I hereby claim:

  • I am 0xdeepmehta on github.
  • I am 0xdeep (https://keybase.io/0xdeep) on keybase.
  • I have a public key ASAc7aDaxliaTiue5o7P9My2K1gtw5Jvh6vuwkQsr1S9Pwo

To claim this, I am signing this object:

@0xdeepmehta
0xdeepmehta / transfer_sol_to_remaining_account.md
Last active September 7, 2022 18:10
transfer sol to remaining_account in anchor

Rust

I’ve been lucky to work primarily in systems where each of these pieces is type safe. At Twitch, we used PostgreSQL for data, Golang for backend, GraphQL for APIs, and React + TypeScript for the front end. Each piece was type safe, and tools like GraphQL allowed us to write a “type contract” between different type systems (in this case a GraphQL schema).

use anchor_lang::prelude::*;
use anchor_lang::solana_program::{program::invoke ,system_instruction::transfer};

declare_id!("CR7XiGZHEu588YMkg2RPtyokwhawwEczcHHznXM6NwG7");
@0xdeepmehta
0xdeepmehta / get_tx.ts
Created July 20, 2022 08:03
get all tx of an account
import {
Connection,
clusterApiUrl,
ConfirmedSignatureInfo,
PublicKey,
} from "@solana/web3.js";
import * as anchor from "@project-serum/anchor";
describe("ohana-contract", () => {
const connection = new Connection(clusterApiUrl("mainnet-beta"));
var axios = require('axios');
var data = JSON.stringify({
"username": "coolkid",
"logo_cid": "ohfuckthecidbish",
"bio": "hey bish",
"token_name": "BISH",
"token_address": "aahbishtheid",
"fund_target": 40,
"fund_duration": 50,
"fund_distributed": []