Skip to content

Instantly share code, notes, and snippets.

View tomarsachin2271's full-sized avatar
🚀
Building tools to enable blockchain mass adoption

Sachin Tomar tomarsachin2271

🚀
Building tools to enable blockchain mass adoption
View GitHub Profile
@tomarsachin2271
tomarsachin2271 / getBundlerBalances.ts
Created April 30, 2024 14:09
Script to get all bundler balances
import { ethers } from 'ethers';
// Replace with your actual JSON RPC URL for the Polygon network
const jsonRpcProviderUrl = 'https://rpc.ankr.com/polygon';
// Replace with your actual list of addresses
const addresses = [
"0xbae8a5e668769ad612f45758306dc1961de9a645",
"0xc251a9fb38f6272813f7d8b50dfc1b68400764b4",
"0x931ea9c1f469c56481fa33c23d365092e3f473cb",
@tomarsachin2271
tomarsachin2271 / generate-api-key.ts
Created April 20, 2024 08:14
Script to generate random API Keys
import * as shortid from "shortid";
import { v4 as uuidv4 } from "uuid";
const createApiKey = (apiKeyPrefix: string): string =>
`${apiKeyPrefix}.${uuidv4()}`;
function generateApiKey(): string {
const apiKeyPrefix = shortid.generate();
return createApiKey(apiKeyPrefix);
/**
*Submitted for verification at BscScan.com on 2021-02-19
*/
pragma solidity ^0.6.2;
interface IERC20 {
function totalSupply() external view returns (uint256);
// To enable meta transaction, let create a generic method that calls executeMetaTransaction by taking the user signature
// and then execute transaction via Biconomy
// Dependencies
import {toBuffer} from "ethereumjs-util";
import abi from "ethereumjs-abi";
import events from "events";
// Initialization of web3
let web3 = new Web3(window.ethereum);

Keybase proof

I hereby claim:

  • I am tomarsachin2271 on github.
  • I am sachintomar (https://keybase.io/sachintomar) on keybase.
  • I have a public key ASBs8oJiSmyBGKXzb6BY2jGt3DAURUtJDqEG4epUijkI7Qo

To claim this, I am signing this object:

@tomarsachin2271
tomarsachin2271 / meta-transaction.js
Created November 6, 2019 12:19
Gist showing how easy it is to use biconomy meta transaction. No need to change existing way of calling your functions
let bookReads = new web3.eth.Contract(abi, address);
bookReads.methods.addToFav(bookId).send({from: userAddress}).on("transactionHash", (hash) => {
// Get Transaction Hash
}).once("confirmation", (confirmationCount, receipt) => {
// Get Transaction Confirmation
}).on("error", (error)=>{
// Error During Transaction
});
@tomarsachin2271
tomarsachin2271 / user-login.js
Last active November 6, 2019 12:12
Gist showing how to do user login using biconomy SDK
biconomy.login(<public wallet address>, (error, response) => {
if(response.transactionHash) {
// First time user. Contract wallet transaction pending. Wait for confirmation.
} else if(response.userContract) {
// Existing user login successful
}
});
biconomy.on(biconomy.LOGIN_CONFIRMATION, (log) => {
// User's Contract Wallet creation successful
@tomarsachin2271
tomarsachin2271 / biconomy-init.js
Last active November 6, 2019 12:11
Gist showing how to initialize biconomy
biconomy.on(biconomy.READY, () => {
// Initialize your dapp here
}).on(biconomy.ERROR, (error, message) => {
// Handle error while initializing mexa
});
import Biconomy from "@biconomy/mexa";
const biconomy = new Biconomy(<web3 provider>,{dappId: <DApp ID>, apiKey: <API Key>});
web3 = new Web3(biconomy);
const subscription = web3.eth.subscribe('logs',{
topics:['0x5983cdcaa370320b76fe01a3a32a0430e6a13b9f47a55e806afb13b5aef95a12']
}, function(error, result){
if(error) {
console.error(error);
}
}).on("data", function(log) {
console.debug(log);
});