Skip to content

Instantly share code, notes, and snippets.

View ankushswar1's full-sized avatar
🃏

Ankush Swarnakar ankushswar1

🃏
View GitHub Profile
@ankushswar1
ankushswar1 / adapter.ts
Last active August 15, 2023 16:45
ReservoirWallet adapter using Gelato relay for gasless transactions
import type { ReservoirWallet } from '@reservoir0x/reservoir-sdk';
import { GelatoRelay } from '@gelatonetwork/relay-sdk';
import type { Signer } from 'ethers/lib/ethers';
import { arrayify } from 'ethers/lib/utils';
import type { TypedDataSigner } from '@ethersproject/abstract-signer/lib/index';
import { getTaskStatus } from './poll';
const sleep = (time: number) => new Promise((resolve) => setTimeout(resolve, time));
// Helper function to poll the status of a Gelato relay task given the taskId
@ankushswar1
ankushswar1 / permitUSDC.ts
Last active July 25, 2023 11:03
USDC Permit on Mumbai
import { getClient, type ReservoirWallet } from '@reservoir0x/reservoir-sdk';
import { GelatoRelay } from "@gelatonetwork/relay-sdk";
import { ConnectedWallet } from '@privy-io/react-auth';
import { ethers } from 'ethers';
import { getTaskStatus } from './poll';
import USDC_ABI from './usdcABI.json';
import {ethers} from 'ethers';
const GELATO_API_KEY = process.env.NEXT_PUBLIC_GELATO_API_KEY || "";
@ankushswar1
ankushswar1 / permitWithGelato.ts
Last active July 21, 2023 14:04
Permit USDC with Gelato
// These values are for Goerli
const CHAIN_ID = '0x5';
const USDC_ABI = 'import USDC ABI as JSON';
const USDC_ADDRESS = '0x07865c6e87b9f70255377e024ace6630c1eaa37f';
const SEAPORT_CONDUIT_ADDRESS = '0x1E0049783F008A0085193E00003D00cd54003c71';
const PERMIT_DOMAIN = {
"name": "USD Coin",
"version": "2",
"chainId": CHAIN_ID,
@ankushswar1
ankushswar1 / gelatoAdapter.ts
Last active July 10, 2023 20:54
ReservoirWallet adapter using Gelato Relayer
import type { ReservoirWallet } from '@reservoir0x/reservoir-sdk';
import { GelatoRelay } from "@gelatonetwork/relay-sdk";
import { arrayify } from 'ethers/lib/utils';
import type { Web3Provider } from '@ethersproject/providers';
import type { TypedDataSigner } from '@ethersproject/abstract-signer/lib/index';
const sleep = (time: number) => new Promise((resolve) => setTimeout(resolve, time));
const getTaskStatus = async (taskId: string) => {
let taskState;
@ankushswar1
ankushswar1 / quickstart.js
Last active July 23, 2022 12:59
Privy Quickstart Demo
import {PrivyClient} from '@privy-io/privy-node';
const PRIVY_API_KEY = '<retrieved from the Privy console>';
const PRIVY_API_SECRET = '<retrieved from the Privy console>';
export default async function quickstart() {
const client = new PrivyClient(PRIVY_API_KEY, PRIVY_API_SECRET);
await client.put('0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B', 'first-name', 'Vitalik');