Skip to content

Instantly share code, notes, and snippets.

View jac18281828's full-sized avatar
🦌

John Cairns jac18281828

🦌
View GitHub Profile
@jac18281828
jac18281828 / geth.sh
Created July 21, 2024 23:04
geth console test commands
web3.fromWei(eth.getBalance("0x6DB1F3F7a368d5895256A5BA0bdB84d2a6C3bFF7"), "ether")
web3.eth.sendTransaction({
from: "0x6DB1F3F7a368d5895256A5BA0bdB84d2a6C3bFF7",
to: "0x1c0ffeec0ffeec0ffeec0ffeec0ffeec0ffee7ea",
value: web3.toWei(1, "gwei")
})
web3.fromWei(eth.getBalance("0x1c0ffeec0ffeec0ffeec0ffeec0ffeec0ffee7ea"), "ether")
@jac18281828
jac18281828 / Dockerfile.geth
Last active July 21, 2024 22:43
Bootstrap an Ethereum Node with Docker
FROM debian:stable-slim AS go-builder
# defined from build kit
# DOCKER_BUILDKIT=1 docker build . -t ...
ARG TARGETARCH
RUN export DEBIAN_FRONTEND=noninteractive && \
apt update && \
apt install -y -q --no-install-recommends \
git curl gnupg2 build-essential coreutils \
openssl libssl-dev pkg-config \
@jac18281828
jac18281828 / PermissionedNodeRegistry.sol
Created July 2, 2024 19:11
PermissionedNodeRegistry with counting tabultation
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.16;
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import { UtilLib } from "./library/UtilLib.sol";
@jac18281828
jac18281828 / UpdateRate.md
Last active June 28, 2024 18:04
How to call 'updateRate()' on ETHxRateProvider

UpdateRate must be called from time to time on Stader ETHxRateProvider, an L2 Rate Oracle for ETHx. The following steps demonstrate how to do this.

Deployment address – Ethereum mainnet:

ETHX_RATE_PROVIDER=0x0B2fAadfe75fE6507Dc8F81f8331198C65cA2C24

1. Check LayerZero fee for sending rate information.

@jac18281828
jac18281828 / QuoteSend.sol
Created June 18, 2024 19:35
Remix Quote Send for OFT
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;
struct SendParam {
uint32 dstEid; // Destination endpoint ID.
bytes32 to; // Recipient address.
uint256 amountLD; // Amount to send in local decimals.
uint256 minAmountLD; // Minimum amount to send in local decimals.
bytes extraOptions; // Additional options supplied by the caller to be used in the LayerZero message.
bytes composeMsg; // The composed message for the send() operation.
// SPDX-License-Identifier: GNU-3.0-or-later
pragma solidity ^0.8.22;
import { Script, console } from "forge-std/Script.sol";
import { OptionsBuilder } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/libs/OptionsBuilder.sol"; // OFT imports
import {
SendParam,
OFTReceipt,
OFTLimit,
@jac18281828
jac18281828 / Dockerfile
Last active May 9, 2024 23:19
Dockerfile for Node 14, smart contract development with Python 3.8
FROM ghcr.io/collectivexyz/foundry:latest
RUN sudo apt update -y && sudo apt upgrade -y
RUN sudo apt remove python3 -y
RUN sudo apt autoremove -y
RUN sudo apt install -y wget build-essential checkinstall libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
RUN mkdir -p /usr/local/src
RUN sudo chown -R foundry:foundry /usr/local/src
WORKDIR /usr/local/src
RUN wget https://www.python.org/ftp/python/3.10.9/Python-3.10.9.tgz
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;
// Mock imports
import { OFTMock } from "./mocks/OFTMock.sol";
import { ERC20Mock } from "./mocks/ERC20Mock.sol";
import { OFTComposerMock } from "./mocks/OFTComposerMock.sol";
// OApp imports
import {
@jac18281828
jac18281828 / ETHx_OFTAdapter.sol
Created May 1, 2024 21:38
ETHx_OFTAdapter example with message sending
// SPDX-License-Identifier: GNU-3.0-or-later
pragma solidity 0.8.22;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { OFTAdapter } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/OFTAdapter.sol";
import { OptionsBuilder } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/libs/OptionsBuilder.sol";
import { MessagingFee } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
import { IPausable } from "./IPausable.sol";
@jac18281828
jac18281828 / MyOFT.t.sol
Created April 22, 2024 15:38
LayerZero Example OFT Test
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
// Mock imports
import { OFTMock } from "./mocks/OFTMock.sol";
import { ERC20Mock } from "./mocks/ERC20Mock.sol";
import { OFTComposerMock } from "./mocks/OFTComposerMock.sol";
// OApp imports
import {