Skip to content

Instantly share code, notes, and snippets.

View nakajo2011's full-sized avatar

Yukishige Nakajo nakajo2011

View GitHub Profile
@nakajo2011
nakajo2011 / contracts...BlindTransfer.sol
Created January 4, 2023 11:23
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.17+commit.8df45f5f.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
* @title FlashTransfer
* @dev Simple blind transfer contract
*/
contract BlindTransfer {
@nakajo2011
nakajo2011 / App.tsx
Created May 3, 2021 08:35
Apollo Client/Getting Started sample4
import React from 'react';
import './App.css';
import './ExchangeRates'
import ExchangeRates from "./ExchangeRates";
export default function App() {
return (
<div>
<h2>My first Apollo app 🚀</h2>
@nakajo2011
nakajo2011 / index.tsx
Created May 3, 2021 08:29
Apollo Client/Getting Started sample3
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import fetch from 'cross-fetch';
import { gql, ApolloProvider, ApolloClient, HttpLink, InMemoryCache } from '@apollo/client';
const endpoint = 'https://48p1r2roz4.sse.codesandbox.io' // apolloのGetting Started
@nakajo2011
nakajo2011 / ExchangeRates.tsx
Last active May 3, 2021 08:31
Apollo Client/Getting Started sample2
import {gql, useQuery} from '@apollo/client';
const EXCHANGE_RATES = gql`
query GetExchangeRates {
rates(currency: "USD") {
currency
rate
}
}
`;
@nakajo2011
nakajo2011 / index.mjs
Last active May 3, 2021 08:07
Apollo Client/Getting Started sample
import fetch from 'cross-fetch';
import { gql, ApolloClient, HttpLink, InMemoryCache } from '@apollo/client';
const client = new ApolloClient({
link: new HttpLink({ uri: 'https://48p1r2roz4.sse.codesandbox.io', fetch }),
cache: new InMemoryCache()
});
client
.query({
query: gql`
query GetRates {
@nakajo2011
nakajo2011 / ModExp.sol
Created March 16, 2021 10:26
ModExp sample on Solidity
pragma solidity ^0.8.1;
contract ModExpContracts {
address public constant modExpAddress = 0x0000000000000000000000000000000000000005;
bytes public _result;
function modExp(
uint baseLength,
@nakajo2011
nakajo2011 / PanicTest.sol
Last active February 24, 2021 01:15
GBEC 2021.02.25 sample code
pragma solidity >= 0.8.0;
contract CalledContract {
uint[] nums;
function onlyEven(uint256 a) external pure returns(uint) {
uint b = 300 / a;
require(b % 2 == 0, "Ups! Reverting");
return b;
@nakajo2011
nakajo2011 / miner_stop_correct_test.js
Created July 7, 2020 14:25
arround freeze sendTransaction.
const pify = require('pify')
async function queueTransaction(from, to, value, nonce, gasLimit, data) {
const response = await pify(web3.currentProvider.send)({
jsonrpc: "2.0",
method: "eth_sendTransaction",
id: new Date().getTime(),
params: [
{
from: from,
@nakajo2011
nakajo2011 / miner_stop_test.js
Last active July 7, 2020 14:26
miner.stop test, but it happen error.
it('multi transfer in same block', async () => {
web3.extend({property: 'mine', methods: [{ name: 'start', call: 'miner_start', params:0}]})
web3.extend({property: 'mine', methods: [{ name: 'stop', call: 'miner_stop', params:0}]})
const instance = await MyERC20Token.new()
const beforeBlock = await web3.eth.getBlockNumber()
await web3.mine.stop()
// queued tx1
@nakajo2011
nakajo2011 / SimpleDonationManager.sol
Last active May 27, 2020 10:50
Using immutable keyword
pragma solidity >=0.6.5;
contract SimpleDonationManager {
uint256 immutable minDonation = 42;
uint256 immutable maxDonation = calcMaxDonation();
address immutable owner;
constructor() public {
owner = msg.sender;
// Error: Immutables cannot be read in constructor.
// assert(minDonation <= maxDonation);
// Error: Immutables can only be assigned once.