Skip to content

Instantly share code, notes, and snippets.

View uF4No's full-sized avatar

Antonio uF4No

View GitHub Profile
@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 / 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 / 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 / ZKsync Remix paymaster transaction
Created December 18, 2024 10:31
Script to send an EIP712 transaction via paymaster on ZKsync using Remix
import * as ethers from "ethers";
import {Provider, Contract, utils, Signer, BrowserProvider, Wallet} from "zksync-ethers";
// Address of the ZeekMessages contract
const GREETER_CONTRACT_ADDRESS = "0x2f5Fa95a28EEd40DD80ED3fFC718094EB41253b4";
// Address of the ERC20 token contract
const TOKEN_CONTRACT_ADDRESS = "0xF4dF2c515581A9fA5bAa078d04703c0f3Fd9115a";
// Message to be sent to the contract
const NEW_MESSAGE = "This tx cost me no ETH!";