Skip to content

Instantly share code, notes, and snippets.

View uF4No's full-sized avatar

Antonio uF4No

View GitHub Profile
@uF4No
uF4No / Paymaster.sol
Created April 24, 2023 17:02
zkSync basic Paymaster implementation
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;
import {IPaymaster, ExecutionResult, PAYMASTER_VALIDATION_SUCCESS_MAGIC}
from "@matterlabs/zksync-contracts/l2/system-contracts/interfaces/IPaymaster.sol";
import {IPaymasterFlow} from "@matterlabs/zksync-contracts/l2/system-contracts/interfaces/IPaymasterFlow.sol";
import {TransactionHelper, Transaction} from "@matterlabs/zksync-contracts/l2/system-contracts/libraries/TransactionHelper.sol";
import "@matterlabs/zksync-contracts/l2/system-contracts/Constants.sol";
@uF4No
uF4No / SmartAccount.sol
Last active April 24, 2023 16:33
zkSync Era smart contract account
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
import "@matterlabs/zksync-contracts/l2/system-contracts/interfaces/IAccount.sol";
import "@matterlabs/zksync-contracts/l2/system-contracts/libraries/TransactionHelper.sol";
// Access zkSync system contracts for nonce validation via NONCE_HOLDER_SYSTEM_CONTRACT
import "@matterlabs/zksync-contracts/l2/system-contracts/Constants.sol";
// to call non-view function of system contracts
import "@matterlabs/zksync-contracts/l2/system-contracts/libraries/SystemContractsCaller.sol";
@uF4No
uF4No / wss-contract-disconnect.js
Last active June 23, 2022 16:39
Simulates how to control websocket errors connecting to a blockchain node
var Web3 = require('web3')
const ABI = [
{
constant: true,
inputs: [],
name: 'name',
outputs: [
{
name: '',
@uF4No
uF4No / ethers-provider-fallback.js
Created March 17, 2022 12:03
how to use multiple RPC endpoints with ethers to reconnect on error
const { ethers } = require('ethers')
const endpoints = [
// main rpc endpoint
'http://localhost:8545',
// fallback one
'https://fallback-rpc-endpoint/12345',
// fallback two
'https://another-fallback-rpc-endpoint/12345',
]
{"version":1,"resource":"file:///Users/antonio/Projects/Golang/webserver/main.go","entries":[{"id":"16Pv.go","timestamp":1655909033736},{"id":"PaA1.go","timestamp":1655909065055},{"id":"YuRI.go","timestamp":1655909287786},{"id":"W3b7.go","timestamp":1655909317411},{"id":"nHEJ.go","timestamp":1655909337878}]}
'use strict'
// To use AWS secrets
//const AWS = require('aws-sdk');
const MongoClient = require('mongodb').MongoClient
//Performance optimization Step 1: declare the database connection object outside
//the handler method so it's cached
let cachedDb = null
@uF4No
uF4No / SubscribeForm.vue
Created December 14, 2019 12:23
A Vue.js subscribe form using Vuetify
<template>
<section id="subscribe" class="bg-white">
<v-container>
<v-row row wrap>
<v-col sm="10" offset-sm="1" md="8" offset-md="2">
<h2 class="display-2 text-center mb-3">Do you want to know more?</h2>
<p class="subheading text-center">
Subscribe to receive updates about the project and be one of the firsts to access!
</p>
@uF4No
uF4No / index.html
Created October 26, 2019 11:33
socket.io chat client html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- Loads socket.io client from server -->
<!-- <script src="/socket.io/socket.io.js"></script> -->
@uF4No
uF4No / calendarService.js
Created May 4, 2019 18:13
Methods to interact with the Google Calendar API
/**
* calendarService.js
*
* Methods to interact with the Google Calendar API
*
*/
const {google} = require('googleapis');
const debug = require('debug')('gcal:calendarService')
/**
@uF4No
uF4No / googleAuth.js
Created May 4, 2019 17:47
exports function to generate an authenticated OAuth2 client for Google APIs
/**
* googleAuth.js
*
* Generates an OAuthClient to be used by an API service
* Requires path to file that contains clientId/clientSecret and scopes
*/
const {google} = require('googleapis');
const fs = require('fs');